Get an error that won't allow me to load my index page. Weird cause my friend has the same exact code and it works.
error: Notice: Trying to get property of non-object in C:\xampp\htdocs\index.php on line 102
Notice: Trying to get property of non-object in C:\xampp\htdocs\index.php on line 107
Fatal error: Call to a member function fetch_assoc() on boolean in C:\xampp\htdocs\index.php on line 109
Code:
if(!isset($_GET['round'])){
$currentgame=$mysql->query('SELECT `value` FROM `info` WHERE `name`="current_game"')->fetch_assoc();
$currentgame=(int)$currentgame['value'];
}else{
$currentgame=(int)$_GET['round'];
}
//GAME INFO ARRAY AND PLAYERS COUNT
$gameinfo=$mysql->query('SELECT * FROM `games` WHERE `id`="'.$currentgame.'"')->fetch_assoc();
$players=$mysql->query('SELECT DISTINCT `userid` FROM `'.$prf.$currentgame.'`');
$playersnum=$players->num_rows;
// ITEMS NUMBER AND GAME TOTAL VALUE
$items=$mysql->query('SELECT * FROM `'.$prf.$currentgame.'` ORDER BY `value` DESC');
$itemsnum=$items->num_rows;
$originalgamevalue=$mysql->query('SELECT SUM(`value`) AS `total` FROM `'.$prf.$currentgame.'`')->fetch_assoc();
$originalgamevalue=(float)$originalgamevalue['total'];
$gamevalue=myround($originalgamevalue);
// TIMELEFT IN GAME
if($gameinfo['starttime'] == 2147483647){
$timeleft=$site['gametime'];
}else{
$timeleft = $gameinfo['starttime']+($site['gametime']-time());
$timeleft=$timeleft-2; //compensate for page loading times
if($timeleft<0){
$timeleft=0;
}
}
I am making a connection to the database, as on other pages it grabs stuff from the database and the error doesn't say unable to connect to database.