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
 
    