Hi I am trying to teach myself some php and get this error (below) when I query a sql database this is just a tutorial and will never go live.

I have hilighted the area in bold where the unseen error is.

Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /var/www/dbconnect1.php on line 14

<?php

        $dbhost = "localhost";
        $dbuser = "root";
        $dbpassword= "password";
        $dbdatabase = "productsdb";

        $db = mysql_connect($dbhost, $dbuser, $dbpassword);
        mysql_select_db($database, $db);

                $sql = "SELECT * FROM products";
                $result = mysql_query($sql);

                [B]while ($row = mysql_fetch_assoc($result)) {
                        echo $row['product'];[/B]
                        }

?>

please go easy on me as am a novice...

I would use mysql_fetch_array instead of mysql_fetch_assoc.

But your problem lies here:

mysql_select_db ($[B]db[/B]database, $db);
commented: =') +4

thanks so simple but just could not see it, its been driving me crazy.......

cant believe i could see that.