Page 1 of 1

mysql_fetch_array(): supplied argument is not a valid MySQL

Posted: Mon Mar 17, 2003 10:32 pm
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

Posted: Mon Mar 17, 2003 11:15 pm
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.

Posted: Wed Mar 19, 2003 7:21 am
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