Faracus Posted June 16, 2009 Share Posted June 16, 2009 I am having a little trouble with some code. mysql_select_db("admin", $con);$result = mysql_query("SELECT tempcode FROM adminsWHERE tempcode !=''");while($row = mysql_fetch_array($result)) { echo $row['tempcode']; echo "<br />"; }?> That is the code and I am given the error of "Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /www/uuuq.com/s/h/a/shackguys/htdocs/admin/check.php on line 19" which is the "while($row)......." Link to comment Share on other sites More sharing options...
justsomeguy Posted June 16, 2009 Share Posted June 16, 2009 That means the query failed, you can use the mysql_error function to get the error message from MySQL. Link to comment Share on other sites More sharing options...
Faracus Posted June 16, 2009 Author Share Posted June 16, 2009 wow it's been a rough day. I totally poster the wrong code lolz. {$con = mysql_connect("localhost","user","password");if (!$con) { die('Could not connect: ' . mysql_error()); }mysql_select_db("shackguys_admin", $con);$sql="INSERT INTO admins (tempcode)VALUES('$_POST[tempcode]')";if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); }echo "Code Created.<br /><form action='create.php' method='post'>Code: <input type='text' name='tempcode' /><br /><input type='submit' value='create' /></form>";mysql_close($con);}?> with line 19 starting at { die('Could not connect: ' . mysql_error()); }It makes little sense to me that the same code in all my other pages fails on this one. Link to comment Share on other sites More sharing options...
justsomeguy Posted June 16, 2009 Share Posted June 16, 2009 This error message:Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /www/uuuq.com/s/h/a/shackguys/htdocs/admin/check.php on line 19Means that a query failed. That error message does not go with the second code you posted, that error is triggered by the mysql_fetch_array function, which was in the first code you posted, but not the second. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.