Possible Duplicate:
PHP Error: mysql_fetch_array() expects parameter 1 to be resource, boolean given
Hello everyone and good day to all
I have a very strange error this morning and iv been trying to solve it for the past 4 hours with no success.
After executing the below code i get this error:
mysql_num_rows() expects parameter 1 to be resource, boolean given in
$per_page = 4;
require_once('Connections/webiceberg.php');
$sql = "select * from services" ;
$rsd = mysql_query($sql);
$count = mysql_num_rows($rsd);
$pages = ceil($count/$per_page);
But then when i edit this line of code to give me an error i get No Database Selected.
$count = mysql_num_rows($rsd) or die (mysql_error());
Whats up , how can i fix this, why is this happening, its like it cant connect to the db even when on another page iam viewing records from the same table just fine.
Any help will be most appreciated.
I think that’s incorrect useage of
mysql_query.It requires the database to be specified to – so it should be something like this:
Because of this,
$rsdisfalsewhen you runmysql_num_rows(), hence the warning about the boolean.Hope this helps
EDIT: useage isn’t techincally incorrect, as the link_identifier parameter is optional, however as detailed here: http://php.net/manual/en/function.mysql-query.php , if you don’t specify the database connection it will try to guess and / or connect on its own which is probably not working, hence the error.