Jump to content

[SOLVED] what's wrong with my mysql_query syntax?


ShoeLace1291

Recommended Posts

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.

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

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.  ;D

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.