Ashoar Posted April 13, 2009 Share Posted April 13, 2009 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. Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted April 13, 2009 Share Posted April 13, 2009 Variables within single quotes will be parsed. Remove the single quotes Quote Link to comment Share on other sites More sharing options...
Ashoar Posted April 13, 2009 Author Share Posted April 13, 2009 I originally had no single quotes so i added them to see if it would work. Either way, those num_rows do not work with or without quotes although they did on an older version of php. Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted April 13, 2009 Share Posted April 13, 2009 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 Quote Link to comment Share on other sites More sharing options...
Ashoar Posted April 13, 2009 Author Share Posted April 13, 2009 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.