致命错误:在我网站上的布尔值上调用成员函数fetch_assoc()[重复]

This question already has an answer here:

Im trying to take out the game id from the database but im having trouble with it. And i do it like this:

if(!isset($_GET['round'])){
    $currentgame=$mysql->query('SELECT `value` FROM `info` WHERE `name`="current_game"')->fetch_assoc();
    $currentgame=(int)$currentgame['value'];

The error that comes up is Fatal error: Call to a member function fetch_assoc() on boolean in C:\xampp\htdocs\index.php on line 85

I have no clue on what i might be doing wrong.

</div>

Without seeing all of your code, I'm assuming there's an error thrown by MySQL - possibly to do with the name="current_game"' section.

You should catch all errors when you're performing an action on a MySQL database. The error you're seeing at the moment is from MySQL returning boolean value FALSE.

Add something like this to your code:

if (!$currentgame) {
    throw new Exception("Database Error [{$mysql->query->errno}] {$mysql->query->error}");
}

This should help you work out what error is being returned.