search

Home  >  Q&A  >  body text

When connecting to the database, when executing the query statement, it appears that $result is a bool value. What exactly is wrong?

微信图片_20180305114204.png

You bad badYou bad bad2497 days ago1610

reply all(3)I'll reply

  • 陈刚

    陈刚2018-03-06 14:39:05

    You need to use the fetchAll() function to obtain the query results. You have only executed the query and have not obtained the query results!

    reply
    0
  • 辉

    2018-03-05 21:45:11

    mysql_query() only returns a resource for SELECT, SHOW, DESCRIBE, EXPLAIN and other statements. If there is an error in the query, it returns FALSE.

    The return value should be a resource object, and you can use foreach to read the content. If the return value is false, it means that your sql statement is wrong. Of course, this prompt will appear in the connect sucess after connecting to the database in your code. If this step does not appear, it means that your database connection has not been successful. It may be that the user name and password of the database are incorrect, or the database service is not turned on. Find it yourself.

    reply
    0
  • You bad bad

    I also think there is something wrong with the query quotation, but there is nothing wrong with just two very straightforward sentences. cake is the table name

    You bad bad · 2018-03-05 22:39:33
  • 大辉狼

    大辉狼2018-03-05 12:47:54

    8FZ2H$H%}O_O9O@T1XWLOTY.png

    If the bool value you are talking about is

    False

    , that is normal.

    reply
    0
  • You bad bad

    Then why does the foreach loop and print report an error?

    You bad bad · 2018-03-05 17:26:55
  • Cancelreply