I apologise upfront this is really simply but causing me much annoyance. I have only been working on PHP a week or so and really learning by need at the minute. Below is my current issue. I am trying to pick up the Google Referral Keyword. Managed that now cant understand why it wont insert the value into the dbase table.
// capture referral url
$referringPage = parse_url( $_SERVER['HTTP_REFERER'] );
if ( stristr( $referringPage['host'], 'google.' ) )
{
parse_str( $referringPage['query'], $queryVars );
echo $queryVars['q']; // This is the search term used
}
// general form data insert
$sql="INSERT INTO refer_kws (kwid, keyword)
VALUES('','what value should I have here')";
if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
echo "";
mysql_close($con)
?>
I have tried several of the options and they just keep inputting Array as the value?? But when I use “? echo $_GET[‘q’] ?” on the page it works fine and displays the value?
I know this is simple. I really do but just cant get it.
You shouldn’t put the array between ”, that will make it a string. Because the string value of an array is “Array” it will store “Array” in the database.
VALUES('',$referringPage)