Help me in my MySql
#1

pawn Код:
//=======================================================================================
stock Connect_To_Database(){
    mysql_connect(SQL_HOST, SQL_USER, SQL_DATA, SQL_PASS);
    if(mysql_ping() != 0){
        print("[DayZ - MySQL] Connect to MySQL Database successfully !");
    }
    else
    {
        print("[DayZ - MySQL] Can't connect to MySQL Database | Trying Again !");
        mysql_connect(SQL_HOST, SQL_USER, SQL_DATA, SQL_PASS);
        if(mysql_ping() != 1){
            print("[DayZ - MySQL] Connect to MySQL Database successfully !");
        }
        else{
            print("[DayZ - MySQL] Can't connect to MySQL Database | Server Closed !");
            SendRconCommand("exit");
        }
    }
    return true;
}
//=======================================================================================
stock mysql_CheckAccount(playerid){
    new Query[128],Name[MAX_PLAYER_NAME],count;
    GetPlayerName(playerid, Name, MAX_PLAYER_NAME);
    mysql_real_escape_string(Name, Name);
    format(Query, sizeof(Query), "SELECT * FROM `accounts` WHERE `Name` = '%s'", Name);
    mysql_query(Query);
    mysql_store_result();
    count = mysql_num_rows();
    mysql_free_result();
    return count;
}
//=======================================================================================
stock CreateAccount(playerid, pass[]){
    new query[256],Name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, Name, MAX_PLAYER_NAME);
    mysql_real_escape_string(Name,Name);
    mysql_real_escape_string(pass,pass);
    format(query, sizeof(query), "INSERT INTO `accounts` (`Name`, `Password`) VALUES ('%s', '%s')", Name, pass);
    mysql_query(query);
    return true;
}
//=======================================================================================
stock mysql_ReturnPassword(Name[]){
    new query[130], Get[130];
    mysql_real_escape_string(Name, Name);
    format(query, 128, "SELECT `password` FROM `accounts` WHERE `Name` = '%s'", Name);
    mysql_query(query);
    mysql_store_result();
    mysql_fetch_row(Get);
    mysql_free_result();
    return Get;
}
//=======================================================================================
stock mysql_GetInt(Table[], Field[], Where[], Is[]){
    new query[128];
    mysql_real_escape_string(Table, Table);
    mysql_real_escape_string(Field, Field);
    mysql_real_escape_string(Where, Where);
    mysql_real_escape_string(Is, Is);
    format(query, 128, "SELECT `%s` FROM `%s` WHERE `%s` = '%s'", Field, Table, Where, Is);
    mysql_query(query);
    mysql_store_result();
    new sqlint = mysql_fetch_int();
    mysql_free_result();
    return sqlint;
}
//=======================================================================================
stock mysql_GetString(Table[], Field[], Where[], Is[]){
    new query[128], Get[128];
    mysql_real_escape_string(Table, Table);
    mysql_real_escape_string(Field, Field);
    mysql_real_escape_string(Where, Where);
    mysql_real_escape_string(Is, Is);
    format(query, 128, "SELECT `%s` FROM `%s` WHERE `%s` = '%s'", Field, Table, Where, Is);
    mysql_query(query);
    mysql_store_result();
    mysql_fetch_row(Get);
    mysql_free_result();
    return Get;
}

This is the MYSQL logs
Код:
[16:12:25] ---------------------------

[16:12:25] MySQL Debugging activated (10/26/14)

[16:12:25] ---------------------------

[16:12:25]  

[16:12:25] >> mysql_connect( )

[16:12:25] CMySQLHandler::CMySQLHandler() - constructor called.

[16:12:25] CMySQLHandler::CMySQLHandler() - Connecting to "192.168.1.39" | DB: "dayz.db" | Username: "root" ...

[16:12:25] CMySQLHandler::Connect() - Host '888-PC' is not allowed to connect to this MySQL server (Error ID: 1130)

[16:12:25] >> mysql_ping( Connection handle: 1 )

[16:12:25] CMySQLHandler::Ping() - You cannot call this function now. (Reason: Dead Connection)

[16:14:12]  

[16:14:12] ---------------------------

[16:14:12] MySQL Debugging activated (10/26/14)

[16:14:12] ---------------------------

[16:14:12]  

[16:14:12] >> mysql_connect( )

[16:14:12] CMySQLHandler::CMySQLHandler() - constructor called.

[16:14:12] CMySQLHandler::CMySQLHandler() - Connecting to "888-PC" | DB: "dayz.db" | Username: "root" ...

[16:14:12] CMySQLHandler::Connect() - Host '888-PC' is not allowed to connect to this MySQL server (Error ID: 1130)

[16:14:12] >> mysql_ping( Connection handle: 1 )

[16:14:12] CMySQLHandler::Ping() - You cannot call this function now. (Reason: Dead Connection)

[16:14:37] >> mysql_real_escape_string( Connection handle: 1 )
This is my MySql

pawn Код:
//====[ Defines // Enums // Forwards // ... ]====
//MySQL:
#define SQL_HOST   "888-PC"
#define SQL_USER   "root"
#define SQL_PASS   ""
#define SQL_DATA   "dayz.db"

Please help me
Reply


Messages In This Thread
Help me in my MySql - by Lloyde - 26.10.2014, 08:27
Re: Help me in my MySql - by Lloyde - 26.10.2014, 08:30
Re: Help me in my MySql - by SaintMikey - 26.10.2014, 08:31
Re: Help me in my MySql - by Lloyde - 26.10.2014, 08:32
Re: Help me in my MySql - by Lloyde - 26.10.2014, 08:35
Re: Help me in my MySql - by Lloyde - 26.10.2014, 08:41

Forum Jump:


Users browsing this thread: 1 Guest(s)