3raser Posted September 12, 2011 Share Posted September 12, 2011 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 'key FROM applications WHERE key = '0188f'' at line 1 Code: function randomNum() { $random = substr(md5(rand(5000,300000)), -5); $query = mysql_query("SELECT key FROM applications WHERE key = $random") or die(mysql_error()); //make sure it doesn't already exist if(mysql_num_rows($query) > 0) { randomNum(); } else { return $random; } } I simply cannot seem to figure out what is happening...I've tried many solutions, but all seem to fail. Link to comment https://forums.phpfreaks.com/topic/246940-where-is-the-coming-from/ Share on other sites More sharing options...
HDFilmMaker2112 Posted September 12, 2011 Share Posted September 12, 2011 Isn't "key" a reserved mysql word? Maybe MySQL is trying to escape it. Link to comment https://forums.phpfreaks.com/topic/246940-where-is-the-coming-from/#findComment-1268208 Share on other sites More sharing options...
3raser Posted September 12, 2011 Author Share Posted September 12, 2011 Isn't "key" a reserved mysql word? Maybe MySQL is trying to escape it. Thank you kind sir. I don't believe how many times I've had this same problem before, but I can NEVER REMEMBER TO ESCAPE RESERVED KEYWORDS. Gah! Anyways, once again, I thank you. Link to comment https://forums.phpfreaks.com/topic/246940-where-is-the-coming-from/#findComment-1268211 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.