Error "Call to a Member Function query() on a non-object in"

Asked

Viewed 39 times

0

Any idea what’s going wrong? What should I do to make it work properly? Thank you in advance for your attention !!

Fatal error: Call to a Member Function query() on a non-object in C: Users.... xampp htdocs install.php on line 4

    <?PHP
//######################## SHOW TICKERS AND NEWS #######################
$time = time();
    $query = $SQL->query("SELECT * FROM `players` ORDER BY `experience` DESC")->fetch();
    $query2 = $SQL->query('SELECT `id`, `name` FROM `players` ORDER BY `id` DESC LIMIT 1;')->fetch();
    $housesfree = $SQL->query('SELECT COUNT(*) FROM `houses` WHERE `owner`=0;')->fetch();
    $housesrented = $SQL->query('SELECT COUNT(*) FROM `houses` WHERE `owner`=1;')->fetch();
    $players = $SQL->query('SELECT COUNT(*) FROM `players` WHERE `id`>0;')->fetch();
    $accounts = $SQL->query('SELECT COUNT(*) FROM `accounts` WHERE `id`>0;')->fetch();
    //$banned = $SQL->query('SELECT COUNT(*) FROM `bans` WHERE `id`>0;')->fetch();
    $guilds = $SQL->query('SELECT COUNT(*) FROM `guilds` WHERE `id`>0;')->fetch();
    ///End Queries ///
  • puts the section where you make the connection to the database, because this $SQL is not a Database Object Defined, there is an error before the connection.

  • The file does not have the connection snippet. In fact I believe it is in another file .php. I am completely inexperienced in .php. Follow the link with the link: https://pastebin.com/GKcq3SBR

  • Where the variable $SQL is defined?

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.