monkeypaw201 Posted May 10, 2008 Share Posted May 10, 2008 <?php $con = mysql_connect("localhost","user","pass"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("my_db", $con); $result = mysql_query("SELECT * FROM smf_messages"); while($row = mysql_fetch_array($result)) { echo "hi"; } mysql_close($con); ?> the error: PHP Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in test.php on line 13 Link to comment https://forums.phpfreaks.com/topic/105033-mysql_fetch_array-error/ Share on other sites More sharing options...
rarebit Posted May 10, 2008 Share Posted May 10, 2008 mysql_select_db("my_db", $con) or die(mysql_error());; $result = mysql_query("SELECT * FROM smf_messages") or die(mysql_error()); see if you get any errors from these? Link to comment https://forums.phpfreaks.com/topic/105033-mysql_fetch_array-error/#findComment-537626 Share on other sites More sharing options...
cheechm Posted May 10, 2008 Share Posted May 10, 2008 Or this $con = mysql_connect("localhost","user","pass"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("my_db", $con); $result = mysql_query("SELECT * FROM smf_messages"); while($row = @mysql_fetch_array($result)) { echo "hi"; } mysql_close($con); Link to comment https://forums.phpfreaks.com/topic/105033-mysql_fetch_array-error/#findComment-537633 Share on other sites More sharing options...
PFMaBiSmAd Posted May 10, 2008 Share Posted May 10, 2008 The query is failing. Suppressing the error will never make the code work. The cause of errors need to be found and fixed. Link to comment https://forums.phpfreaks.com/topic/105033-mysql_fetch_array-error/#findComment-537680 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.