my script returns this error:
Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in C:\wamp\www\php_test\user_inter.php on line 17

$db = mysql_connect("localhost");

mysql_select_db("room_p7", $db);

$query = "select * from members";
$result = mysql_query($query);


        while(list($fieldname, $fieldvalue) = each($record)){

            echo $fieldname.": <br>".$fieldvalue.":<br><br>";

    echo "<br><br>";


Recommended Answers

Answered by pritaeas 2,061 in a post from

Your connect has no user/password, the query fails.

Jump to Post

All 4 Replies

Your connect has no user/password, the query fails.

commented: sorry, didn't saw your answer, bye! +8

Add or die(mysql_error()); both to line 2 and 4 (and also 7 if you want to check the query). Probably you need to set username, password in mysql_connect(), because if there is no database connection, mysql_query() returns false and you get that error.

$result = mysql_query($query);

in this line

$result = mysql_query($query , $db);

Here is the conection string,
My Username - root,
My PW - ;

$con = mysql_connect("localhost", "root", "") or die("Oops ! Server Not Connected");
$db = mysql_select_db("Your_DB") or die("Oops ! DB Not Connected");

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.