At 14:10 09/11/2002 +0000, you wrote:
Message-ID: <000201c28788$00d50e20$0200a8c0@ncus>
From: "Zeus" <[EMAIL PROTECTED]>
Subject: mysql_fetch_array problem

I try to display mysql database using fetch_array but there seem to problem,
i m new with PHP and mysql.I didn't quite sure, what's worng with my codes.i havent include the formyet. the error messages:
Warning: mysql_fetch_field(): supplied argument is not a valid MySQL result
resource in c:\apache\htdocs\zeus\shoutbox.php on line 17
I think the problem lies in the line below :

$result = mysql_query("SELECT * FROM shoutbox BY ID desc LIMIT 5");

shoud read ORDER BY :

$result = mysql_query("SELECT * FROM shoutbox ORDER BY ID desc LIMIT 5");
=========

If the SQL is not correctly formed, you will not get a result set - hence your error (not a valid MySQL result means no results were returned)

To check for returned results, use the function like this :

if (mysql_num_rows($result)==0) {

print ("No results returned - please check query");

} else {

.. rest of your code - while loop etc.

}

You can always chec a query by printing it, then cut & paste into mysql console or (better imho) insert it into the query box in phpmyadmin - you will get more useful / less cryptic information there.

Hope that helps,
Regards,
Neil Smith.



--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to