mysql_fetch_array(): supplied argument is not a valid MySQL

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
valen53
Forum Contributor
Posts: 137
Joined: Tue Aug 27, 2002 9:29 am

mysql_fetch_array(): supplied argument is not a valid MySQL

Post by valen53 »

<?
$con=mysql_connect("SERVER","","") or die ("Couldn't connect to SQL Server on SERVER");
$con1=mysql_select_db("project");

$result = mysql_query("select * from corder");
while ($row = mysql_fetch_array($result));
{
echo $row["OrderID"] ;
}
?>

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\Apache Group\Apache\htdocs\jin yi\test.php on line 6

OS: win 98 : client
web server : Apache in w2k 2000: server

i can't find out the error, b'cos my PHPMyAdmin was run properly in my web server. anyone else know the error ???
i can run this source file in my home standalone PC , but cannot run in my office network .
thank to helping
User avatar
phice
Moderator
Posts: 1416
Joined: Sat Apr 20, 2002 3:14 pm
Location: Dallas, TX
Contact:

Post by phice »

Code: Select all

while ($row = mysql_fetch_array($result));
should be...

Code: Select all

while ($row = mysql_fetch_array($result))
remove the ; at the end of the while loop line.
Image Image
User avatar
Ebula
Forum Newbie
Posts: 15
Joined: Wed Mar 19, 2003 7:21 am
Location: Hamburg, Germany

Post by Ebula »

Use mysql_error(); to check if the query works properly, and maybe try to use mysql_num_rows($result); to check if the query returns anthing at all.

Cheers,

Ebula
Post Reply