Faracus Posted June 16, 2009 Report 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 Report 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 Report 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 Report 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
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now