0

Can anyone help. This used to work fine on my old server. Then I transferred it across to a new server and I get the same fatal error. From my understanding the prepare statement fails and gets a value of FALSE but I don't understand whats causing this.

$query = " 
        SELECT 
            id, 
            username, 
            password, 
            salt, 
            email 
        FROM User 
        WHERE 
            username = :username 
    "; 

    // The parameter values 
    $query_params = array( 
        ':username' => $_POST['username'] 
    ); 

    try { 
        $stmt = $db->prepare($query); 
        $result = $stmt->execute($query_params); 
    } 
    catch(PDOException $ex) { 
       die("Failed to run query: " . $ex->getMessage()); 
        //echo $ex->getMessage();
    } 

Error:

Fatal error: Uncaught Error: Call to a member function execute() on boolean in index.php:36 Stack trace: #0 {main} thrown in index.php on line 36
bd808
  • 1,781
  • 1
  • 22
  • 31
Tom
  • 9,725
  • 3
  • 31
  • 48

0 Answers0