Trying to get property of non-object / Call to a member function bind_param() on boolean

前端 未结 2 1281
半阙折子戏
半阙折子戏 2021-01-17 01:08

I am aware that this question has been asked many times but the solutions doesn\'t seem to be working for me.

I am writing a simple blog and I wanted to make an arch

2条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-17 01:40

    In regards to your updated status, fetch_assoc() is not a member of a mysqli statement object. However, fetch() is and is the member function you are looking for.

    You can also use bind_result() to access the data.

    So an example would look something like:

        $timestamp = time();
    
        //create select statement
        $stmt = $con->prepare("SELECT column_x, column_y, column_z FROM table_name WHERE date < ?");
    
        //bind $timestamp to the prepared statement
        $stmt->bind_param("i", $timestamp);
        $stmt->execute();
    
        //bind each selected column to a variable for iteration
        $stmt->bind_result($column_x, $column_y, $column_z);
        while($stmt->fetch())
        {
            echo $x . " " . $y . " " . $z . "\n";
        }
    

    Here is the reference link for the mysqli_stmt class

    edit: I would also like to point out that while a mysli_stmt object does have a num_rows property, it is not the same as the num_rows property on a query result.

提交回复
热议问题