ShoeLace1291 Posted January 27, 2009 Share Posted January 27, 2009 For a while now, I've been using CodeIgniter(which might have been a mistake). Now I'm trying to code my clan's website in straight up PHP and none of my queries are working. Whenever I try to run a query, I get this error: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\xampp\htdocs\fourthcore\template\index_body.tpl on line 12 I can't figure out what's wrong with my queries. Here is my code: <?php $query = mysql_query("SELECT * FROM fc_matches ORDER BY matchID DESC LIMIT 5"); if(mysql_num_rows($query) == 0){ echo "<h2>There are no matches to display.</h2>"; } else { while($fetch=mysql_fetch_array($query)){ echo "<li><a href='matches.php?view=".$fetch["matchID"].">".$fetch["opponent"]."</a></li>"; } } ?> Thanks for any help. Quote Link to comment https://forums.phpfreaks.com/topic/142678-solved-whats-wrong-with-my-mysql_query-syntax/ Share on other sites More sharing options...
bluesoul Posted January 27, 2009 Share Posted January 27, 2009 See my signature and let me know what happens. Quote Link to comment https://forums.phpfreaks.com/topic/142678-solved-whats-wrong-with-my-mysql_query-syntax/#findComment-747854 Share on other sites More sharing options...
MadTechie Posted January 27, 2009 Share Posted January 27, 2009 in other word $query = mysql_query("SELECT * FROM fc_matches ORDER BY matchID DESC LIMIT 5") or die(mysql_error()); See my signature and let me know what happens. I tried it and got #1064 - 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 'foo' at line 1 Quote Link to comment https://forums.phpfreaks.com/topic/142678-solved-whats-wrong-with-my-mysql_query-syntax/#findComment-747860 Share on other sites More sharing options...
ShoeLace1291 Posted January 27, 2009 Author Share Posted January 27, 2009 LOL, forgot about mysql_error... thanks. Got it fixed. Quote Link to comment https://forums.phpfreaks.com/topic/142678-solved-whats-wrong-with-my-mysql_query-syntax/#findComment-747862 Share on other sites More sharing options...
bluesoul Posted January 27, 2009 Share Posted January 27, 2009 in other word $query = mysql_query("SELECT * FROM fc_matches ORDER BY matchID DESC LIMIT 5") or die(mysql_error()); See my signature and let me know what happens. I tried it and got #1064 - 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 'foo' at line 1 Well there's the problem obviously. Quote Link to comment https://forums.phpfreaks.com/topic/142678-solved-whats-wrong-with-my-mysql_query-syntax/#findComment-747864 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.