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

MySQL on local server

Comments in 'Plugin Development' started by MyNameIsTriXz, Aug 11, 2016.

  1. MyNameIsTriXz
    Offline

    MyNameIsTriXz Notable Member

    Joined:
    Aug 17, 2015
    Posts:
    538
    Minecraft User:
    MyNameIsTriXz
    I try to setup MySQL on my local server, whenever I start the connection with
    PHP:
    $con = new mysqli("sql7.freemysqlhosting.net""sql7131012""<secret>""sql7131012");

    if (
    $con->connect_error) {
    error_log("error");
    var_dump("error");
        die(
    'Connect Error (' $mysqli->connect_errno ') '
               
    $con->connect_error);
    }else{
    var_dump("MYSQLI SUCCESS");
    }
    and then boot my server on my Android app, PocketMine just stops, whenever my plugin is loading. I also tested it on my Server for PHP app, where you can setup an own server, the code works fine, and even creates connection. So why does my server stop when it attempts to create a connection with MySQL?
  2. PocketKiller
    Offline

    PocketKiller Notable Member

    Joined:
    Jul 20, 2015
    Posts:
    741
    Because of the die() you have made...
  3. MyNameIsTriXz
    Offline

    MyNameIsTriXz Notable Member

    Joined:
    Aug 17, 2015
    Posts:
    538
    Minecraft User:
    MyNameIsTriXz
    Still stops
  4. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    $mysqli is undefined.
    PocketKiller likes this.
  5. MyNameIsTriXz
    Offline

    MyNameIsTriXz Notable Member

    Joined:
    Aug 17, 2015
    Posts:
    538
    Minecraft User:
    MyNameIsTriXz
    I removed that part, I think it's a PocketMine error
  6. MyNameIsTriXz
    Offline

    MyNameIsTriXz Notable Member

    Joined:
    Aug 17, 2015
    Posts:
    538
    Minecraft User:
    MyNameIsTriXz
    PocketMine also stops whenever I do file_get_contents("http://example.com"); , it stops if I do something internet related like MySQLi, file_get_contents (on url), cURL, or sockets. Is that nornal?
  7. PocketKiller
    Offline

    PocketKiller Notable Member

    Joined:
    Jul 20, 2015
    Posts:
    741
    Use AsyncTask.
    MyNameIsTriXz likes this.
  8. MyNameIsTriXz
    Offline

    MyNameIsTriXz Notable Member

    Joined:
    Aug 17, 2015
    Posts:
    538
    Minecraft User:
    MyNameIsTriXz
    For MySQLi connection too?
  9. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    That has nothing to do with the question...
    applqpak and SOFe like this.
  10. MyNameIsTriXz
    Offline

    MyNameIsTriXz Notable Member

    Joined:
    Aug 17, 2015
    Posts:
    538
    Minecraft User:
    MyNameIsTriXz
    Okay, I found the problem, it doesn't work on my local hosted server on my phone. It worked as I tested it on a free host. Does it work when you test it on a local server on Linux, Windows or Mac?
  11. SOFe
    Offline

    SOFe Banned

    Joined:
    May 28, 2016
    Posts:
    386
    Minecraft User:
    Herobrine
    I don't know how many times you have edited that, so I don't know if this is the obvious problem.

    On Linux, there is a special mysqld.sock file that you may need to explicitly link as the last parameter to mysqli::__construct() if mysqli cannot detect the proper path.
    Android is Linux too. Not sure if this is also true on Android, which has a Linux-like environment (Always remember, although Android supports most Linux commands and uses Java for its apps, Android has no native Java and Android is not directly Linux!). I don't know how you installed MySQL on your Android phone either.

    Perhaps you should use this syntax instead.
    PHP:
    $con = @new \mysqli(...);
    if(
    $con->connect_error){
      echo 
    $con->connect_error;
      return 
    null;
    }
    This may work better on Android.
    If it still doesn't work, download PHP binaries for Android and start a PocketMine server through a CLI (e.g. Termux) to retrieve all output.
    applqpak and MyNameIsTriXz like this.
  12. Tim // robske Büba
    Offline

    Tim // robske Büba Notable Member

    Joined:
    Feb 26, 2014
    Posts:
    606
    Minecraft User:
    robske_110
    I think like @SOFe that the php bins for android don't like to work as the normal one for UNIX. Same with windows (welcome segfaults).
  13. DC4CODE
    Offline

    DC4CODE Active Member

    Joined:
    Nov 19, 2015
    Posts:
    64
    Minecraft User:
    dxdsc9349
    Off Topic..

    Do you really trust freemysqlhosting.net?
    Websites like that are a bit not trustworthy...
    Just saying for the sake of security I would buy a VPS and run my own MySQL Server.
  14. DC4CODE
    Offline

    DC4CODE Active Member

    Joined:
    Nov 19, 2015
    Posts:
    64
    Minecraft User:
    dxdsc9349
    Depends what your using it for.

    For Authentication it is highly insecure.

    But for like a leaderboard or a stats systems it should be ok...
  15. MyNameIsTriXz
    Offline

    MyNameIsTriXz Notable Member

    Joined:
    Aug 17, 2015
    Posts:
    538
    Minecraft User:
    MyNameIsTriXz
    I use it temporary, for tests. When I am going to open a server, then I have a VPS server.
  16. SOFe
    Offline

    SOFe Banned

    Joined:
    May 28, 2016
    Posts:
    386
    Minecraft User:
    Herobrine
    Why not test it on a computer? mysqld is pretty easy to install from a computer, even Windows.
    DC4CODE and applqpak like this.
  17. MyNameIsTriXz
    Offline

    MyNameIsTriXz Notable Member

    Joined:
    Aug 17, 2015
    Posts:
    538
    Minecraft User:
    MyNameIsTriXz
    I rather use a phone than PC, I even write plugins on it (ik not good)

Share This Page

Advertisement