Jump to content

Why this warning? "mysql_fetch_array() applied argument not valid..."


evansste
 Share

Recommended Posts

What I'm trying to do seems pretty simple and straight forward. However, I continue to get this same warning. The warning reads: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /mnt/vhosts/mysite.com/httpdocs/test.php on line 12 I'm trying to add the contents of one table to another. The following is the entire program that I'm trying to run. I've only changed, the "username" and "password". <?php$con = mysql_connect("localhost","username","xxxxxxx");if (!$con){ die('Could not connect: ' . mysql_error());}mysql_select_db("data",$con); $workarg = "INSERT INTO list1 SELECT * FROM list1R";$result = mysql_query($workarg) or die(mysql_error()); while($row = mysql_fetch_array($result)){ echo "try it.",'<br />';}mysql_close($con);?> There's something about line 12 that the computer just doesn't like. As you can see, I used the "or die" option as a suggestion from other posts, but it doesn't even say why I get the warning. This may be because the program doesn't actually stop. It does function. It adds the contents of table "list1R" to "list1". But I still don't know why I get this message. Does anyone have any ideas as to why this may be happening? Thanks for your time, and any help you may be willing to offer.

Link to comment
Share on other sites

"$workarg" is the argument for "mysql_query". I decided to place the argument in a variable so that the lines wouldn't be so long. I'm trying to use "mysql_fetch_array" on "$result", which gives me the warning. So why isn't "$result" a valid MySQL resource? I thought that maybe I had the syntax wrong for "$workarg". So I tried using the following for "$workarg": $workarg = "INSERT INTO list1 (rank,URL,IDnum) SELECT * FROM list1R"; I thought that because I didn't declare the columns for "list1" that this was the reason for the warning. However, even after using the above line for "$workarg", I still get the warning. I still don't understand why.

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...