Possible Duplicate:
PHP Error: mysql_fetch_array() expects parameter 1 to be resource, boolean given
I am trying to build an array from a mysql object after querying.
The number or rows returned in the query is 68, this is why I thought a forloop would be good. However php does not like my code inside the forloop.
Here is the code:
$result = $db->query("SELECT * FROM `networktariff`");
$rows = mysql_num_rows($result);
for ($i= 0; $i<$rows; $i++)
{
$tariffs[$i] = mysql_fetch_assoc($result[$i]);
}
I am getting an error message saying :
Warning: mysql_fetch_assoc() expects parameter 1 to be resource, null given in /usr/local/www/apache22/data/quote/index.php on line 58
There is no such thing like
"mysql object".Your
$dbobject belongs to some user-defined class and there is no point in asking anyone about this class’ behavior.Assuming that
query()method just utilizing ordinary mysql_query() function call, it does return aresource, not object.If you have a strange idea of using some class to run the query yet bare API functions for the rest,
I dunno though why your class doesn’t have some helper function to get the whole data at once, something like