dizzy1 Posted January 20, 2009 Share Posted January 20, 2009 hi, im tryin to find out how may rows thier are in a sql im doing, the answer should be 0. THis is the error msg i get: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/fhlinux144/user/htdocs/Search.php on line 388 $mysql = " Select * from "; $mysql .= " venue "; $temp = mysql_query($mysql); Line 338: $NumRows = mysql_num_rows($temp); echo "NumRows: $NumRows <br>"; i need to know the value of NumRows so i can see if the value is not equal to 0 so it will continue if ($NumRows != 0 ){ //DO SOMTHING } Thanks In Advance Dizzy Link to comment https://forums.phpfreaks.com/topic/141598-solved-mysql-result-resource-error/ Share on other sites More sharing options...
redarrow Posted January 20, 2009 Share Posted January 20, 2009 <?php $result = $mysqli->query("SELECT COUNT(*) as TOTALFOUND from table"); $row_array=$result->fetch_array(MYSQLI_ASSOC); print($row_array['TOTALFOUND']); ?> Link to comment https://forums.phpfreaks.com/topic/141598-solved-mysql-result-resource-error/#findComment-741139 Share on other sites More sharing options...
redarrow Posted January 20, 2009 Share Posted January 20, 2009 $mysql = " Select count(*) from "; $mysql .= " venue "; $temp = mysql_query($mysql); Line 338: $NumRows = mysql_num_rows($temp); echo "NumRows: $NumRows <br>"; Link to comment https://forums.phpfreaks.com/topic/141598-solved-mysql-result-resource-error/#findComment-741142 Share on other sites More sharing options...
revraz Posted January 20, 2009 Share Posted January 20, 2009 Use mysql_error() after your query to see why your query is failing. Link to comment https://forums.phpfreaks.com/topic/141598-solved-mysql-result-resource-error/#findComment-741143 Share on other sites More sharing options...
dizzy1 Posted January 20, 2009 Author Share Posted January 20, 2009 i changed it to: $mysql = " Select * from "; $mysql .= " venue "; $temp = mysql_query($mysql); if(mysql_num_rows($temp) != 0) { { But still didnt work i tried changing the mysql_query to fetch_array and the error turned into a fatal error. i tried puttin in mysql_error(); all over the place and it didnt do anything. help me please ??? Link to comment https://forums.phpfreaks.com/topic/141598-solved-mysql-result-resource-error/#findComment-741151 Share on other sites More sharing options...
redarrow Posted January 20, 2009 Share Posted January 20, 2009 <?php $temp = mysql_query($mysql)or die(mysql_error()); ?> <<< add it tell us what failing mate. Link to comment https://forums.phpfreaks.com/topic/141598-solved-mysql-result-resource-error/#findComment-741152 Share on other sites More sharing options...
revraz Posted January 20, 2009 Share Posted January 20, 2009 $mysql = "Select * from venue"; $temp = mysql_query($mysql) or die (mysql_error()); Link to comment https://forums.phpfreaks.com/topic/141598-solved-mysql-result-resource-error/#findComment-741153 Share on other sites More sharing options...
dizzy1 Posted January 20, 2009 Author Share Posted January 20, 2009 <?php $temp = mysql_query($mysql)or die(mysql_error()); ?> <<< add it tell us what failing mate. Cheers everyone tat is a brilliant piece of syntax mysql_error(), when used correctly, it basically told me the table didnt exist and the reason it didnt exist was becuase the damn table callled venue should of been spelt Venue, capital V. THANKS EVERYONE FOR ALL YOUR TIME AND PATIENCE. ;D Link to comment https://forums.phpfreaks.com/topic/141598-solved-mysql-result-resource-error/#findComment-741161 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.