Hi, I know this is an easy fix, but I'm tired, so I cant seem to find it. Heres my code. I know it had something to do with my mysql query. Its for my website, http://tenimizer.com $usernameid = $_GET["extra"]; $findboard = mysql_query("SELECT * FROM boards WHERE to='$usernameid'") or die(mysql_error()); while($fb = mysql_fetch_array($findboard)) { PHP: Here's my error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'to=Ryan' at line 1 Code (markup): Please help.
$findboard = mysql_query("SELECT * FROM boards WHERE to=$usernameid") or die(mysql_error()); and if this not work, then i think in the database you have set the type (integer/INT) of field (to) Regards
"to" is a reserved word. Please take a look here: http://dev.mysql.com/doc/refman/5.0/en/reserved-words.html and here: http://dev.mysql.com/doc/mysqld-version-reference/en/mysqld-version-reference-reservedwords-5-0.html I would try to change the table's column named "to" into something that's not on the reserved words list. Please confirm if it works after changing the name.
You can do either that, or wrap the word into backticks. SELECT * FROM boards WHERE `to` = '$usernameid' Code (sql): Ah yeah, and ESCAPE YOUR INPUT: $usernameid = mysql_real_escape_string($_GET["extra"]); PHP: Today's homework is reading this page: www.php.net/mysql_real_escape_string
Full example: $usernameid = mysql_real_escape_string($_GET["extra"]); $findboard = mysql_query("SELECT * FROM boards WHERE `to`='" . $usernameid . "'") or die(mysql_error()); while($fb = mysql_fetch_array($findboard)) { } Code (markup): Please don't add $variables within a string, better to add them as displayed above!
Hi, Yes, I did the Real_escape_string, just didnt include it in here, also, changing the word to, to something like boardTo, worked great, and fixed the problem. Thanks everyone! - http://tenimizer.com