致命错误:在null中调用成员函数prepare()

时间:2016-04-05 15:09:33

标签: php mysql pdo prepared-statement

是的,我知道另一个(抱歉)该错误在$ statement = $ pdo->准备就绪。我有另一个功能与这个功能非常类似,它使用相同的细节并且有效。所以我错过了什么或....

/*DATA SQL ACCESS*/
$serverNetwork = "REDACTED";
$username = "REDACTED";
$server = "REDACTED";
$password = "REDACTED";
$pdo = new PDO($server,$username,$password);
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

function removeResultFromDB($userID, $term){
  global $pdo;
  try{
      $statement = $pdo->prepare("DELETE FROM `ValidSearchResults` WHERE  userID = ? AND searchTerm = ?");
      $statemtnt->execute([$userID, $term]);
  } catch (PDOException $e){
     $statement->error = $e->getMessage();
    var_dump($e);
  }
}
?>

0 个答案:

没有答案