I have this error appearing

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /websites/123reg/LinuxPackage21/th/er/ag/theragereport.co.uk/public_html/feed/feed_view.php on line 148

from this code

$sql3="SELECT view FROM $tbl_name2 WHERE id='40'";


// if have no counter value set counter = 1
$sql4="INSERT INTO $tbl_name(view) VALUES('$view') WHERE id='40'";

// count more value
$sql5="update $tbl_name set view='$addview' WHERE id='40'";

any help would be hot

Regards Ryan Cosans

5 Years
Discussion Span
Last Post by karthik_ppts


Try to isolate what is the mysql_fetch_array output..So, you may want to try running a test query instead. Something like this

if (!($rows = mysql_fetch_array($sql3)))
        return null;
      ## or maybe to print or echo something if there is none, but the return null has to be commented above.
       echo "There is nothing to show";
## if the statement above is false, then we can echo
echo $view;

Another helpful hint is to add or die(mysql_error()); on your query..

$rows=mysql_fetch_array($sql3)or die(mysql_error());

Overall, I prefer to use the first one above, because how about if id = 40 does not even exist due to auto increment?

Edited by veedeoo: n/a


simplypixie is correct. You need to pass resultset as the argument not query. And also check whether the view is keyword of Mysql. We can't use keyword as column name. otherwise change your query as

$sql3="SELECT `view` FROM $tbl_name2 WHERE id='40'";

Edited by karthik_ppts: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.