mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in

Posted by user2533440 on Stack Overflow See other posts from Stack Overflow or by user2533440
Published on 2013-06-28T21:56:27Z Indexed on 2013/06/28 22:21 UTC
Read the original article Hit count: 108

Filed under:
|
|

I cannot figure out whats wrong with this code. Every time i try to run this file I get error mysql_fetch_assoc() expects parameter 1 to be resource

<?php  
            $q = "select * from tbfood";
            $rs = mysql_query($q);                           

            while($msg = mysql_fetch_assoc($rs)){
            echo "<p>".$msg["name"]."</p>";
            echo "<p>".$msg["price"]."</p>";
            if ($msg['idDruh'] == 1) {
                    echo "string1";
                } elseif ($msg['idDruh'] == 2) {
                    echo "string2";
                } elseif ($msg['idDruh'] == 3) {
                    echo "string3";
                } elseif ($msg['idDruh'] == 4) {
                    echo "string4";
                } elseif ($msg['idDruh'] == 5) {
                echo "string5";
                } elseif ($msg['idDruh'] == 6) {
                echo "string6";
                } elseif ($msg['idDruh'] == 7) {
                echo "string7";
                }
            }
           ?>

© Stack Overflow or respective owner

Related posts about php

Related posts about mysql