Jump to content

boolean error


hyster

Recommended Posts

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.