1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

Class mysqli not found

Discussion in 'Plugin Help' started by AbelGamerC, Jan 30, 2017.

  1. AbelGamerC

    AbelGamerC Spider Jockey

    Messages:
    29
    GitHub:
    abelgamerc
    I'm doing a mysql-based plugin, but it says: Class mysqli not found
     
  2. Junkdude

    Junkdude Zombie

    Messages:
    346
    GitHub:
    JunkDaCoder
    PHP:
    public $config = [
                
    "host" => "0.0.0.0",
                
    "user" => "user",
                
    "password" => "password",
                
    "database" => "database",
                
    "port" => 3306
            
    ];
     
    $this->database = new \mysqli($this->config["host"], $this->config["user"], $this->config["password"], $this->config["database"], isset($this->config["port"]) ? $this->config["port"] : 
     
  3. AbelGamerC

    AbelGamerC Spider Jockey

    Messages:
    29
    GitHub:
    abelgamerc
    Don't work in android :/
     
  4. Junkdude

    Junkdude Zombie

    Messages:
    346
    GitHub:
    JunkDaCoder
    *sigh*
    PHP:
    class Main extends PluginBase implements Listener{
        public 
    $config = [
                
    "host" => "0.0.0.0",
                
    "user" => "user",
                
    "password" => "password",
                
    "database" => "database",
                
    "port" => 3306
            
    ];
            public 
    $isSpinning = [];
        public 
    $istesting = [];
        public function 
    onEnable() {
        
    ##EXTERNAL PLUGIN ROUTES###
        
    $this->getServer()->getPluginManager()->registerEvents($this$this);
        
    $this->getServer()->getPluginManager()->registerEvents(new Rewards($this), $this);
        
    $this->getServer()->getPluginManager()->registerEvents(new EventListener($this), $this);
        
    $this->getServer()->getPluginManager()->registerEvents(new Protection($this), $this);
        
    $this->epe $this->getServer()->getPluginManager()->getPlugin("EssentialsPE");
        
    $this->getServer()->getScheduler()->scheduleRepeatingTask(new Hud($this), 100);
        
    $this->getServer()->getScheduler()->scheduleRepeatingTask(new CEChecker($this), 20);
        
    $this->prot = new Protection($this);
        
    $this->reward = new Rewards($this);
        @
    mkdir($this->getDataFolder());
        if(!
    is_dir($this->getDataFolder() . "playersfolder/")) {
            
    mkdir($this->getDataFolder() . "playersfolder/");
            }
        
        
    ##exec("rar a -r pluginbackup+1.rar $path/plugins");
        
    Tile::registerTile(CustomChest::class, true);
        
    $this->database = new \mysqli($this->config["host"], $this->config["user"], $this->config["password"], $this->config["database"], isset($this->config["port"]) ? $this->config["port"] : 3306);
        if(
    $this->database->connect_error){
                    
    $this->getLogger()->critical("Couldn't connect to MySQL: "$this->database->connect_error);
                    
    $this->getServer()->getPluginManager()->disablePlugin($this);
                    return;
                }
        
    $this->getLogger()->info(TF::AQUA "Connected to MySQL!");
        
    $table "CREATE TABLE creditz (
                   ChatMessages INT(255) UNSIGNED DEFAULT 0)"
    ;
        if(
    mysqli_query($this->database$table)){
                                
    $this->getLogger()->notice("Created Mysql Table!");
                            }else{
                                
    $this->getLogger()->critical("Mysql Table Failed To Generate!".mysqli_error($this->database));
         
     
  5. AbelGamerC

    AbelGamerC Spider Jockey

    Messages:
    29
    GitHub:
    abelgamerc
    Don't work..
     
  6. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    You don't need to \mysqli because it is a function (like strtolower(), not \strtolower()).

    Recompile PHP with MySQL.
     
    gistrec likes this.
  7. AbelGamerC

    AbelGamerC Spider Jockey

    Messages:
    29
    GitHub:
    abelgamerc
    Is there any php with mysql for android?
     
  8. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    How did you set up PHP on your Android device?
     
  9. Jack Noordhuis

    Jack Noordhuis Zombie Pigman Poggit Reviewer

    Messages:
    618
    GitHub:
    JackNoordhuis
    It is not a function, it's a class name. The \ is also required due to it being a global class.
     
  10. InspectorGadget

    InspectorGadget Zombie Pigman

    Messages:
    462
    GitHub:
    InspectorGadget
    NetBeans IDE is well known to put \ in front of a PHP function.
     
  11. SOFe

    SOFe Administrator Staff Member PMMP Team Poggit Admin

    Messages:
    1,968
    GitHub:
    sof3
    *sigh* You didn't even understand the problem.
     
    Muqsit and InspectorGadget like this.
  12. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    Is it possible for Android to run this shell script?
    Code:
    #!/bin/bash
    # Requirements: curl, sudo, tar, building tools
    [ -z "${PREFIX}" ] && PREFIX=/usr/local
    [ -w "${PREFIX}" ] || SUDO=sudo
    set -e
    mkdir -p work
    cd work
    curl -fsSL http://www.php.net/distributions/php-7.0.15.tar.xz | tar -xJf - --strip-components=1
    ./configure \
        --disable-cgi \
        --enable-mbstring \
        --enable-bcmath \
        --enable-sockets \
        --with-curl \
        --with-libedit \
        --with-openssl \
        --with-zlib \
        --with-mysqli\
        --enable-pcntl \
        --enable-maintainer-zts \
        --prefix="${PREFIX}"
    make -j`nproc`
    $SUDO make install
    $SUDO "${PREFIX}/bin/pecl" install channel://pecl.php.net/pthreads-3.1.6 channel://pecl.php.net/weakref-0.3.2 channel://pecl.php.net/yaml-2.0.0
    echo "phar.readonly = off
    extension = yaml.so
    extension = pthreads.so
    extension = weakref.so
    zend.assertions = -1
    " | $SUDO tee "${PREFIX}/lib/php.ini" > /dev/null
    cd ..
    rm -rf work
    
     
  13. InspectorGadget

    InspectorGadget Zombie Pigman

    Messages:
    462
    GitHub:
    InspectorGadget
    I have no idea on how to set this up on Android!
     
  14. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    Run the script using ./
     
  15. InspectorGadget

    InspectorGadget Zombie Pigman

    Messages:
    462
    GitHub:
    InspectorGadget
    Only that?! Nice, thanks :)
     
    Muqsit likes this.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.