Fatal error: Call to a member function bindParam()

前端 未结 2 499
遇见更好的自我
遇见更好的自我 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();
    }
    
    0 讨论(0)
  • 2020-12-02 02:06

    Try print_r($db->errorInfo());

    Probably the prepare failed so you can't use it.

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