- Forums
- MySQL
- Warning: Mysql_fetch_row() Expects Parameter 1 To Be Resource, Boolean Given In Php
i was getting this error on my php script using mysql and this is what you need to do to fix this error or warning you are getting on you code [938], Last Updated: Sat May 18, 2024
wallpaperama
Wed Apr 04, 2012
0 Comments
368 Visits
i was getting this error and this is how i fixed it
i was running a query like this:
$sql = "UPDATE mytable set cunter=counter+1 WHERE id=1";
$result = mysql_query($sql ,$database);
if (!$myrow = mysql_fetch_row($result)) {
echo mysql_errr();
}
Warning: mysql_fetch_row() expects parameter 1 to be resource, boolean given in /www/db.php line 6
ok, the problem here is that you are telling mysql to get a array from your query, but you are not fetching anything from your database so its not going to return anything, when in fact you are just updating data in the database, so you need to use
mysql_query() instead of
mysql_fetch_row()so once i changed my code to this, it worked:
$sql = "UPDATE mytable set cunter=counter+1 WHERE id=1";
if (!$mysql_query($sql ,$db)){
echo mysql_errr();
}
no more errors