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 ; Quote 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. Quote 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) ; Quote 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 Quote Link to comment https://forums.phpfreaks.com/topic/224949-boolean-error/#findComment-1161847 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.