Results 1 to 4 of 4
August 12th, 2010, 10:41 AM #1I am Stumped with a PHP/MYSQL problem
I have a search form (_POST) on the top of my pages that goes to a search.php page where I try and retrieve some records from my database.
//Some pseudo code
$find = stripslashes($_POST['find']); mysql_connect("cccc", "ccccc", "cccc"); $find = mysql_real_escape_string( $find ); //Update search activity table echo "[" . $find . "]"; //Prints out the string "green" $query = "INSERT INTO mydb.search (searchfor) VALUES ('$find')"; $result = mysql_query($query);
The problem is that when I look at the latest entry in my search database table, I see a string other than the word "green". I echo $find var on the line before the insert which looks fine.
Last edited by Uncle Rico; August 12th, 2010 at 10:42 AM.
August 13th, 2010, 07:29 AM #2
What happens when you echo $query? What's the structure for the search table?
August 13th, 2010, 07:39 AM #3
Try using unique search values to test each time. So for example for one round use green1a1, then run a select statment to see if that unique value (green1a1) is now in the database.
August 13th, 2010, 05:19 PM #4
- Join Date
- July 23rd, 2010
- Monterrey, Mexico
Hello Uncle Rico,
You forgot to escape the $find variable, use .$varname. to concatenate strings!
$query = "INSERT INTO mydb.search (searchfor) VALUES (" . $find . ")";
Hope this helps!
Last edited by emilioolivares; August 13th, 2010 at 05:20 PM.
By scm21st in forum Midnight Cafe'Replies: 5Last Post: August 5th, 2007, 09:30 PM
By spiderninja in forum Midnight Cafe'Replies: 0Last Post: January 31st, 2007, 10:12 PM
By AddHandler in forum Programming / Datafeeds / ToolsReplies: 13Last Post: May 7th, 2005, 02:25 PM
By perfectG in forum Programming / Datafeeds / ToolsReplies: 1Last Post: November 6th, 2002, 05:58 AM