Jump to content

[SOLVED] 5.2.9 - mysql_num_rows


Ashoar

Recommended Posts

Today i tested my forum software on a higher version of PHP, 5.2.9.

I got a load of errors back everywhere i have used myql_num_rows, saying it is not a valid MySQL result resource.

 

Here is an example of a line it says is incorrect:

$lastreply=mysql_query("SELECT * FROM reply");
if(mysql_num_rows('$lastreply')==0) echo "none";
else
for($i=0;$i<mysql_num_rows($lastreply);$i++) {
$lreply=mysql_fetch_assoc($lastreply);
}

 

The num_rows there are incorrect according to php.

 

Has the structure of it changed in this version?

If so how am i meant to use mysql_num_rows.

Link to comment
Share on other sites

If mysql_num_rows is failing then it usually means your query has failed due to an error. To see if you query is causing an error

Change

$lastreply=mysql_query("SELECT * FROM reply");

 

to

$lastreply=mysql_query("SELECT * FROM reply") or die(mysql_error());

 

Post the error message you get here

Link to comment
Share on other sites

Thank you for that.

I noticed my error once you posted that.

I have no such table as reply. I had re-named it when i cleaned up all of my coding and changed a few things around.

 

Sorry for posting such a silly question, i should of checked to make sure i changed everything properly.

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.