savagenoob Posted December 14, 2010 Share Posted December 14, 2010 For some odd reason, my MySQL array is not returning any data. I echo'd the query and it is correct, I looked at the database and that row is in there, but when I print_r the array, nothing. Here is the code. $infoquery = "SELECT * FROM '$endotype' WHERE ID = '$typeid' ORDER BY ID DESC LIMIT 1"; $info = mysql_query($infoquery); echo $infoquery; $infoout = mysql_fetch_array($info); print_r($infoout); Its a very simple query and its driving me nuts. Quote Link to comment https://forums.phpfreaks.com/topic/221657-query-not-getting-info/ Share on other sites More sharing options...
Maq Posted December 14, 2010 Share Posted December 14, 2010 Add this temporarily to see if your query is failing for some reason: $info = mysql_query($infoquery) or die(mysql_error()); For a live environment you should be handling these errors more appropriately. Quote Link to comment https://forums.phpfreaks.com/topic/221657-query-not-getting-info/#findComment-1147271 Share on other sites More sharing options...
savagenoob Posted December 14, 2010 Author Share Posted December 14, 2010 Obviously, Here is the 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 ''drivers' WHERE ID = '355' ORDER BY ID DESC LIMIT 1' at line 1 Quote Link to comment https://forums.phpfreaks.com/topic/221657-query-not-getting-info/#findComment-1147276 Share on other sites More sharing options...
savagenoob Posted December 14, 2010 Author Share Posted December 14, 2010 Eh, I knew it, something stupid, just changed '$endotype' to $endotype. Quote Link to comment https://forums.phpfreaks.com/topic/221657-query-not-getting-info/#findComment-1147279 Share on other sites More sharing options...
PFMaBiSmAd Posted December 14, 2010 Share Posted December 14, 2010 You have single-quotes around your table name, making it a string rather than a table name. Quote Link to comment https://forums.phpfreaks.com/topic/221657-query-not-getting-info/#findComment-1147280 Share on other sites More sharing options...
Maq Posted December 14, 2010 Share Posted December 14, 2010 Eh, I knew it, something stupid, just changed '$endotype' to $endotype. You may have meant to use backtics to escape the table name in case it's a reserved word. But you should avoid naming tables after reserved words anyway. Quote Link to comment https://forums.phpfreaks.com/topic/221657-query-not-getting-info/#findComment-1147282 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.