Jump to content

Php Where


Faracus
 Share

Recommended Posts

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

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...