Fatal error: Call to a member function bindParam()

前端 未结 2 513
遇见更好的自我
遇见更好的自我 2020-12-02 01:22

I am learning to work with PHP and have a simple problem.



        
2条回答
  •  自闭症患者
    2020-12-02 01:55

    I would check that the $db->prepare() function executed successfully. It will return false if it did not. So you could be trying to call bindParam() on a variable that equals false

    http://www.php.net/manual/en/pdo.prepare.php

    Also you should put the PDO object declaration in try/catch to be sure it was successful as well, as in the first example on this page:

    try {
        $dbh = new PDO($dsn, $user, $password);
    } catch (PDOException $e) {
        echo 'Connection failed: ' . $e->getMessage();
    }
    

提交回复
热议问题