It looks like your sql query failed, so the result is invalid.

Assuming that this is really the whole script, then you're counting on 
the mysql_db_query function to open a connection to the database "db" 
using the default connection values which (according to the manual) are 
host: localhost, user: (whatever user is running the script, probably 
'www', 'apache', or 'nobody' depending on your system), and password: 
(blank). Do you really have your mysql database setup to allow access 
with these defaults?

I'd recommend trying mysql_connect() first, then if that works continue 
on to the mysql_query(). At least you'll know better which aspect failed.


On Friday, March 15, 2002, at 05:14  PM, cosmin laslau wrote:

> <?
> $query = "SELECT * from mytable";
> $result = mysql_db_query("db", $query);
> while ($myarray = mysql_fetch_array($result))
> {
> $title = $myarray[title];
> echo "$title<br>";
> }
> ?>
> Can someone PLEASE tell me why the coding above gives the following 
> error:
> Warning: Supplied argument is not a valid MySQL result resource in 
> /var/web/ on line 5
> It's absurd. It's driving me nuts. I'm about to introduce my computer 
> to the pavement 40 feet below.
> Thanks in advance for whoever sees what I am sure is a glaring and 
> obvious flaw in the coding. I've been looking at it for an hours and 
> just can't get anything from where I'm standing, maybe a different 
> perpective will help.
> _________________________________________________________________
> Get your FREE download of MSN Explorer at 
> -- PHP General Mailing List (
> To unsubscribe, visit:

PHP General Mailing List (
To unsubscribe, visit:

Reply via email to