Craig Hopson Posted January 13, 2012 Share Posted January 13, 2012 hi just learning SQL stuff getting this error thoWarning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource inthis is the script im using <?php$con = mysql_connect("localhost","mysite_test","test1");if (!$con) { die('Could not connect: ' . mysql_error()); }mysql_select_db("my_db", $con);$result = mysql_query("SELECT * FROM test_members");while($row = mysql_fetch_array($result)) { echo $row['FirstName'] . " " . $row['LastName']; echo "<br />"; }?> i know it will be something silly but i'm stuck lol Link to comment Share on other sites More sharing options...
justsomeguy Posted January 13, 2012 Share Posted January 13, 2012 That means the query failed. You can check if it fails and print the error from MySQL: $result = mysql_query("SELECT * FROM test_members") or exit(mysql_error()); Link to comment Share on other sites More sharing options...
Krewe Posted January 14, 2012 Share Posted January 14, 2012 I am pretty sure it detects the connection automatically, however I just want to point out that you can add the connection variable in the mysql_query() so it knows exactly where to look. ex:$result_set = mysql_query($query, $connection) Link to comment Share on other sites More sharing options...
Craig Hopson Posted April 10, 2012 Author Share Posted April 10, 2012 thanks guys Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.