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. 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. 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 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. 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. 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
Archived
This topic is now archived and is closed to further replies.