I have a function that accepts some parameters and a mysqli connection:

Code:
function search($memberselect, $term, $mysqli) {
    /*
     * Check the action (member number, email or surname)
     * Run the appropriate query
     */
//    var_dump($mysqli);
//    exit;
    
    if ( ($memberselect != 'memnum') && ($memberselect != 'surname') && ($memberselect != 'email') ) {
        return FALSE;
    }
    
    $query = 'SELECT * FROM cu3a_members WHERE ' . $memberselect . ' = ?';
    $stmt = $mysqli->prepare( $query );
    
//    var_dump($stmt);
//    exit;
    
    if ( $stmt === FALSE  ) {
        // And so on ...
Whatever I try, the if() statement
Code:
if ( $stmt === FALSE)
always fails. In other words, it appears to me, the call:

Code:
$mysqli->prepare($query)
always returns FALSE

On entering the function, this is what the $mysqli variable contains:

Code:
object(mysqli)#1 (18) { ["affected_rows"]=> int(-1) ["client_info"]=> string(6) "5.5.24" ["client_version"]=> int(50524) ["connect_errno"]=> int(0) ["connect_error"]=> NULL ["errno"]=> int(0) ["error"]=> string(0) "" ["field_count"]=> int(1) ["host_info"]=> string(25) "Localhost via UNIX socket" ["info"]=> NULL ["insert_id"]=> int(0) ["server_info"]=> string(23) "5.5.24-0ubuntu0.12.04.1" ["server_version"]=> int(50524) ["stat"]=> string(134) "Uptime: 3552 Threads: 3 Questions: 396 Slow queries: 0 Opens: 329 Flush tables: 1 Open tables: 80 Queries per second avg: 0.111" ["sqlstate"]=> string(5) "00000" ["protocol_version"]=> int(10) ["thread_id"]=> int(94) ["warning_count"]=> int(0) }
After making the
Code:
mysqli::prepare()
call, this is what the $stmt variable looks like:

Code:
object(mysqli_stmt)#2 (9) { ["affected_rows"]=> int(0) ["insert_id"]=> int(0) ["num_rows"]=> int(0) ["param_count"]=> int(1) ["field_count"]=> int(12) ["errno"]=> int(0) ["error"]=> string(0) "" ["sqlstate"]=> string(5) "00000" ["id"]=> int(2) }
I've tried everything I can think of, so I'm turning to the forum in desperation. If anyone can think of anything else I can try, I'd be more than grateful. If somebody can spot my error, even better!

Cheers

Peredur