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.

Link to comment
Share on other sites

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
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.