monkeytooth Posted January 13, 2010 Share Posted January 13, 2010 mysql_query("SELECT TitleSafe FROM thebook WHERE key='".mysql_real_escape_string($bookKey)."'") or die(mysql_error()); Says I have a syntax error near: key='73350' key is a BIGINT don't know if that means anything to this issue, but thats the whole line throwing the error. Any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/188386-i-dont-see-the-issue-with-this-syntax-help/ Share on other sites More sharing options...
mikesta707 Posted January 13, 2010 Share Posted January 13, 2010 you shouldn't use single quotes for numeric data types. try removing the single quotes Quote Link to comment https://forums.phpfreaks.com/topic/188386-i-dont-see-the-issue-with-this-syntax-help/#findComment-994513 Share on other sites More sharing options...
PFMaBiSmAd Posted January 13, 2010 Share Posted January 13, 2010 Key is a reserved mysql keyword. Change it to something else or enclose it in back-ticks. Quote Link to comment https://forums.phpfreaks.com/topic/188386-i-dont-see-the-issue-with-this-syntax-help/#findComment-994514 Share on other sites More sharing options...
monkeytooth Posted January 13, 2010 Author Share Posted January 13, 2010 Removing the quotes didnt change anything, still get the same error. who ever developed this database used key as someone would use ID, does that still hold the difference as to what you said about key being reserved? id so should I change the name of the whole column to ID or something? Quote Link to comment https://forums.phpfreaks.com/topic/188386-i-dont-see-the-issue-with-this-syntax-help/#findComment-994516 Share on other sites More sharing options...
monkeytooth Posted January 13, 2010 Author Share Posted January 13, 2010 Well decided to change the column name to ID, alter the line of code as such: mysql_query("SELECT TitleSafe FROM thebook WHERE ID=".$bookKey."") or die(mysql_error()); Unfortunately I still get an 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 '' at line 1 I have tried a couple variations of the line as well, with or without quotes, with or without mysql_real_escape_string still the same thing. Quote Link to comment https://forums.phpfreaks.com/topic/188386-i-dont-see-the-issue-with-this-syntax-help/#findComment-994517 Share on other sites More sharing options...
PFMaBiSmAd Posted January 13, 2010 Share Posted January 13, 2010 If you form the query in a variable first, so you can echo it to see exactly what it is, you will probably find that $bookKey is empty. Quote Link to comment https://forums.phpfreaks.com/topic/188386-i-dont-see-the-issue-with-this-syntax-help/#findComment-994519 Share on other sites More sharing options...
monkeytooth Posted January 13, 2010 Author Share Posted January 13, 2010 Cutting out the SQL and echoing the $bookkey var, echo's what the bookkey var is.. searching the db manually through phpmyadmin for the number bookkey shows also yelids a result. Quote Link to comment https://forums.phpfreaks.com/topic/188386-i-dont-see-the-issue-with-this-syntax-help/#findComment-994559 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.