Getting Resource id #3 Error in MySql

后端 未结 2 1860
抹茶落季
抹茶落季 2021-01-13 12:35

I ran this code and I got a Resource id #3 error where it should have showed the full movies table.

mysql_connect(\"localhost\", \"root\", \"password\") or d         


        
2条回答
  •  感动是毒
    2021-01-13 13:02

    You're not getting an error, the MySQL API is just doing what you're asking it to: echoing the contents of $data, which is a MySQL query resource at this point. Extend the code to actually retrieve the results:

    while($row = mysql_fetch_object($data))
        var_dump($row);
    

    And you'll see the output.

    Note that the mysql_* API is deprecated since PHP 5.5 by the way.

提交回复
热议问题