I am trying to upgrade an old application to PHP 7.2. It contains an sql class PHP file with the following function which I have modified to use mysqli:
    function query($query, $index=0)
    {
        // query
        if (!$this->res[$index] = mysqli_query($this->connection, $query))
        {
            // if query fails show error
            $this->error('<strong>invalid query</strong>:<br />' . $query . '<br />');
            return false;
        }
        // statistical information
        $this->num_rows[$index] = @mysqli_num_rows($this->res[$index]);
        $this->num_flds[$index] = @mysqli_num_fields($this->res[$index]);
        $this->num_aff[$index]  = @mysqli_affected_rows($this->connection);
        $this->last_id             = @mysqli_insert_id($this->connection);
        return true;
    }
This function throws the folling error:
E_WARNING Error in file �sql.class.php� at line 132: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given E_WARNING Error in file �sql.class.php� at line 133: mysqli_num_fields() expects parameter 1 to be mysqli_result, boolean given
My initial thought was that the query was failing. However, including this line inside the function...
print_r(mysqli_fetch_assoc($this->res[$index]));
results in the following output:
Array ( [s_id] => 2088b4cc0d026c2742e8e0cb7d7c8e95 )
In the output above, the query is returning a session ID. That leaves me a bit confused because the value of $this->res[$index] is not a boolean, yet the Warning says it is.
Edit:
If I include this in the function:
        echo mysqli_num_rows($this->res[$index]);
        echo mysqli_num_fields($this->res[$index]);
Each line echos the correct value of 1 but each line also produces the boolean Warning...
E_WARNING Error in file �sql.class.php� at line 125: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given
E_WARNING Error in file �sql.class.php� at line 126: mysqli_num_fields() expects parameter 1 to be mysqli_result, boolean given
 
     
    