The following block of code works fine (no errors)
$query = "select * from users where username = ?";
$statement = $sql->prepare($query);
echo gettype($statement); // -- This returns 'object'
$statement->bindParam(1, $username);
The following gives: Fatal error: Call to a member function bindParam() on a non-object in /file.php on line 39
$email = '[email protected]';
$query = "select * from users where email = ?";
$statement = $sql->prepare($query);
echo gettype($statement); // -- this returns 'boolean'
$statement->bindParam(1, $email); // -- this is line 39.
Now this is strange.
At my local machine, and my remote host, this was never a problem.
This errors only shows up on this new hosting company I am trying out for the month. Could it be a config param when they compiled php?
--------edit-------- While still trying to figure out what's wrong,I found this out.
$query = "select userID, username from users";
$statement = $sql->prepare($query);    
$statement->execute();
$r = $statement->fetchAll(PDO::FETCH_ASSOC);
// display # of rows
echo "Rows returned: " . $statement->rowCount();
// display results array
echo '<pre>'; print_r($r); echo '</pre>';
On a server, I get
Rows returned: 4
Array
(
    [0] => Array
        (
            [userID] => 1
            [username] => lyrae
        )
    [1] => Array
        (
            [userID] => 2
            [username] => jproffer
        )
    [2] => Array
        (
            [userID] => 3
            [username] => king
        )
    [3] => Array
        (
            [userID] => 4
            [username] => gergy
        )
)
Which is correct. Says 4 rows returned and displays the result array. On another server however, I get
Rows returned: 0
Array
(
    [0] => Array
        (
            [userID] => 1
            [username] => lyrae
        )
    [1] => Array
        (
            [userID] => 2
            [username] => jproffer
        )
    [2] => Array
        (
            [userID] => 3
            [username] => king
        )
    [3] => Array
        (
            [userID] => 4
            [username] => gergy
        )
)
Thus, it seems also that PDOStatement::rowCount() does not work on a sever but works on another.