cpharry Posted April 24, 2009 Share Posted April 24, 2009 Hi, As youve probably notice im not that good with php however i know a bit. mysql_select_db("wowbasec_class", $connection); $result = mysql_query("SELECT * FROM location"); $result1 = mysql_query("SELECT * FROM char"); $rows = mysql_num_rows($result); I have this at the moment but if i want to put in another count for another table in the same database how do i do that without any errors? Link to comment https://forums.phpfreaks.com/topic/155570-solved-mysql_num_rows-error/ Share on other sites More sharing options...
DjMikeS Posted April 24, 2009 Share Posted April 24, 2009 what are you trying to achieve ? You can just do: $result2 = mysql_query("SELECT * FROM othertable"); Please explain your goal.... Link to comment https://forums.phpfreaks.com/topic/155570-solved-mysql_num_rows-error/#findComment-818705 Share on other sites More sharing options...
Maq Posted April 24, 2009 Share Posted April 24, 2009 $rows1 = mysql_num_rows($result1); Link to comment https://forums.phpfreaks.com/topic/155570-solved-mysql_num_rows-error/#findComment-818708 Share on other sites More sharing options...
Mchl Posted April 24, 2009 Share Posted April 24, 2009 $rows1 = mysql_num_rows($result1); And if you just need to count the rows without actually retrieving them use something like this $result = mysql_query("SELECT COUNT(*) AS locationCount FROM location"); $row = mysql_fetch_array($result); $locationCount = $row['locationCount']; $result1 = mysql_query("SELECT COUNT(*) AS charCount FROM char"); $row1 = mysql_fetch_array($result); $charCount = $row['charCount']; Link to comment https://forums.phpfreaks.com/topic/155570-solved-mysql_num_rows-error/#findComment-818709 Share on other sites More sharing options...
cpharry Posted April 24, 2009 Author Share Posted April 24, 2009 What i want is i want to display... #Locations #Characters etc. But whenever i put in $result2 = mysql_query("SELECT * FROM char"); $rows2 = mysql_num_rows($result2); Extra i get this error... Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/wowbasec/public_html/index.php on line 10 Link to comment https://forums.phpfreaks.com/topic/155570-solved-mysql_num_rows-error/#findComment-818710 Share on other sites More sharing options...
Mchl Posted April 24, 2009 Share Posted April 24, 2009 char is MySQL reserved word. You shouldn't call your table like that... but if you did, use backticks around it's name $result2 = mysql_query("SELECT * FROM `char`"); Here's full list of reserved words http://dev.mysql.com/doc/refman/5.1/en/reserved-words.html Link to comment https://forums.phpfreaks.com/topic/155570-solved-mysql_num_rows-error/#findComment-818712 Share on other sites More sharing options...
cpharry Posted April 24, 2009 Author Share Posted April 24, 2009 Thanks working now will change the db name too thanks Link to comment https://forums.phpfreaks.com/topic/155570-solved-mysql_num_rows-error/#findComment-818713 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.