hyster Posted January 19, 2011 Share Posted January 19, 2011 why does the top code work and the bottom does not? what am i missing? the only real diffrence is the query. im getting "Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in " for this code $numrows = mysql_num_rows($result). the query works fine in phpmyadmin. thanks $query = "SELECT * FROM dsgi_servlist " ; $result = mysql_query($query) ; $numrows = mysql_num_rows($result) ; echo $numrows ; $sql = "SELECT COUNT(*) FROM dsgi_servlist where location = 'hdd'"; $result = mysql_query($sql) ; $numrows = mysql_num_rows($result) ; echo $numrows ; Link to comment https://forums.phpfreaks.com/topic/224949-boolean-error/ Share on other sites More sharing options...
Adam Posted January 19, 2011 Share Posted January 19, 2011 Generally that indicates a MySQL error. mysql_error returns the last error from your session, so trigger an error if mysql_query returns false: $result = mysql_query($sql) or trigger_error('MySQL error: ' . mysql_error(), E_USER_ERROR); That should help you debug the problem. Link to comment https://forums.phpfreaks.com/topic/224949-boolean-error/#findComment-1161836 Share on other sites More sharing options...
dragon_sa Posted January 19, 2011 Share Posted January 19, 2011 does it work if you do this $numrows = mysql_result($result,0) ; Link to comment https://forums.phpfreaks.com/topic/224949-boolean-error/#findComment-1161838 Share on other sites More sharing options...
hyster Posted January 19, 2011 Author Share Posted January 19, 2011 cheers dragon worked a treat Link to comment https://forums.phpfreaks.com/topic/224949-boolean-error/#findComment-1161847 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.