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
https://forums.phpfreaks.com/topic/153828-solved-529-mysql_num_rows/
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

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.

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.