Why i've Fatal error: Call to a member function prepare() on a non-object?

后端 未结 1 1576
误落风尘
误落风尘 2021-01-28 20:11

I\'ve ask a question for PDO error (here But I\'ve a another problem with object...

Here is my code :

include(\'../../config/connexion-bdd.php\');

$nom         


        
相关标签:
1条回答
  • 2021-01-28 20:33

    It is all clear, Your $bdd is not containing a SQL connection. You have to check for the validity of the SQL connection.

    $bdd must be an object, and thus it contains a method called prepare().

    When the connection is not established correctly, the variable $bdd will not be an object and thus will not have a method prepare.

    Now, when you use $bdd->prepare() it throws an error that $bdd is not an object, thus it could not have a method called prepare()

    Now, you should present a var_dump($bdd) before the $bdd->prepare() line for use to inspect it.

    0 讨论(0)
提交回复
热议问题