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. Quote 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. Quote 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. Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.