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

后端 未结 1 900
旧时难觅i
旧时难觅i 2021-01-28 01:29

i am getting this error when trying to perform the following query:

$sql = mysql_query(\"select c.id as id_car, c.year, c.make, c.model, c.type, c.colour, 
              


        
相关标签:
1条回答
  • 2021-01-28 02:23

    The value of $sql is probably false. This happens if the query you tried to execute failed to execute, usually due to a syntax error in the SQL.

    Generally, you want your query code to look like this:

    if ($result = mysql_query ('SELECT * FROM foo WHERE bar = \'baz\''))
    {
        // resultset processing goes here
        while ($row = mysql_fetch_assoc ($result))
        {
        }
    }
    else
    {
        echo (mysql_error ());
    }
    
    0 讨论(0)
提交回复
热议问题