Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

MySQL Error

Comments in 'Plugin Development' started by CraftYourBukkit, Jun 16, 2015.

  1. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    I am (very!) new to MySQL, so I just started coding with/in it.
    My Code:
    PHP:
    public function getCurrentSlots($server) {
            
    $status "current";
            
    $result $this->database->query("SELECT * FROM slots WHERE status='$status' AND server='$server'"); // That's Line 83
            
    if ($result instanceof \mysqli_result) {
                
    $data $result->fetch_assoc();
                
    $result->free();
                if (isset(
    $data["server"]) and $data["server"] === $server) {
                    unset(
    $data["server"]);
                    return 
    $data["amount"];
                }
            }
            return 
    null;
        }
    Error when using the function:
    Code:
    Fatal error: Call to a member function query() on null in C:\Users\fuego\Desktop\Programmieren\Server\PocketMine-MP\plugins\MySQL\src\BukkitPlaysMC\Slots\Main.php  on line 83
    Can anyone tell me what's wrong? :/
    Last edited: Jun 16, 2015
  2. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    $this->database is undefined.
    Also, why did you unset $data["server"]?
  3. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    Idk lol and it isn't actually
  4. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Yes, $this->database is null. Try doing a var_dump() on it.

Share This Page

Advertisement