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

前端 未结 2 1284
半阙折子戏
半阙折子戏 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:43

    Have a read here: http://php.net/manual/en/mysqli.prepare.php prepare you get a false if it fails. Hence your error.

    The issue is your SQL your need to use ? in place of variable names and prepare expects the data to bind. I believe you want:

    $sql = "SELECT * FROM posts WHERE date >= ? AND date <= ? ORDER BY date DESC";
    $stmt->bind_param('ii', $from, $to);
    

提交回复
热议问题