PHP mysqli prepared statement(procedural style) mysqli_prepare fails

$stmt = mysqli_prepare($dbc, $q); always return a Boolean 0 in the code below, so the following binding statement fails. $dbc is good, and I think the prepared query has no problem. Why mysqli_prepare($dbc, $q) always returns 0? What are the possible causes?

    if ($e && $p) { // If email and password are validated.


            /* create a prepared statement */
            $q = "SELECT user_id, first_name, DATE_FORMAT(last_login_time, '%a, %b %e at %l:%i%p') as f_last_login_time, last_login_time FROM users WHERE (email=? AND pass=SHA1(?)) AND active IS NULL";
            $stmt = mysqli_prepare($dbc, $q);

            /* bind parameters for markers */
            mysqli_stmt_bind_param($stmt, "s", $e, $p);

            /* execute query */
            mysqli_stmt_execute($stmt);

            if (@mysqli_num_rows($stmt) == 1) { // A match was made in the user table

                    /* bind result variables */
                    mysqli_stmt_bind_result($stmt, $user_id, $first_name, $f_last_login_time, $last_login_time);

                    /* fetch value */
                    // Fetch the result from a prepared statement into the variables bound by mysqli_stmt_bind_result().
                    mysqli_stmt_fetch($stmt);

                    // Register the values:
                    //$_SESSION = mysqli_fetch_array($r, MYSQLI_ASSOC);
                    // Now must use bound result variables seperately with SESSION:
                    $_SESSION['user_id'] = $user_id;
                    $_SESSION['first_name'] = $first_name;
                    $_SESSION['f_last_login_time'] = $f_last_login_time;
                    $_SESSION['last_login_time'] = $last_login_time;

                    /* close statement */
                    mysqli_stmt_close($stmt);