Im wanting to integrate recent searches and have added an extra field to searchform.php so I know the search came from it and have this in search.php
<?php
//code before
if ($_GET['a']){
$q = $_GET['q'];
@mysql_query("INSERT INTO `price_searches` (`id`,`term`) VALUES ('','$q')");
}
//code after
?>
but it isnt adding it to the price_searches table...
Can anyone help me with this?
Cheers
Figured it out...
I was using a standard insert but your database queries look like they connect to the database as needed and it wasnt connected when mine was trying to do the insert.
Cheers David
Robert
Is "id" an auto-increment INT field? If so; I think you need to specify NULL as the value (or just leave it out) otherwise the query will fail..
Just a bit of guess. Otherwise, have you tried echoing everything to confirm that what you are expecting to be set is set?
What I normally do to debug SQL is to print the query out then exit to make sure that everything is OK, so your code would be something like this:
<?php
//code before
if ($_GET['a']){
$q = $_GET['q'];
$sql = "INSERT INTO `price_searches` (`id`,`term`) VALUES ('','$q')";
print "<p>[".$sql."]</p>";exit();
@mysql_query($sql);
}
//code after
?>
I always use square brackets when printing out variables during debugging - it lets you see if there is any erroneous white space around the values...
Hope this helps!
David.