Mysql mysql_ping undefined?
#1

Hello all,

I just updated the mysql plugin to the latest version.
And now i see mysql_ping is undefined.
Is there something changed with mysql_ping?
Код:
if(mysql_ping() == 1)
Admigo
Reply
#2

This function was descontinued, cause there is no use to it anymore.

The MySQL connection will be always alive until you use mysql_close, or exit your gamemode.
Reply
#3

Quote:
Originally Posted by arakuta
Посмотреть сообщение
This function was descontinued, cause there is no use to it anymore.

The MySQL connection will be always alive until you use mysql_close, or exit your gamemode.
Yes but what about if you lose connection of the mysql database?

EDIT: Or when the server has failed to connect to the database?

pawn Код:
stock ConnectToDatabase()
{
    gSQL = mysql_connect(MYSQL_HOST, MYSQL_USER, MYSQL_DB, MYSQL_PASS);
    printf("Connecting to the Local Database...");
    if(mysql_ping(gSQL) == 1)
    {
        //printf("Successfully connected to the MySQL server");
        printf("Successfully connected to MySQL server | %s", MYSQL_HOST);
    }
    else
    {
        //gSQL = mysql_connect(MYSQL_HOST_HOST, MYSQL_USER_HOST, MYSQL_DB_HOST, MYSQL_PASS_HOST);
        //printf("Connecting to the Hosted Database...");
        printf("Cannot connect to MySQL Server | %s aborting...", MYSQL_HOST);
        //SendRconCommand("exit");
    }
    return 1;
}
Reply
#4

You can use:
pawn Код:
mysql_errno(connectionHandle)
instead of checking mysql_ping.
Reply
#5

Quote:
Originally Posted by Admigo
Посмотреть сообщение
Yes but what about if you lose connection of the mysql database?
I've been using MySQL for about a year, and never got a connection lost, probably it reconnects automatically.
Reply
#6

and what about:
Код:
C:\Users\BRANDON\Desktop\CnR Server 0.3z\pawno\include\acnr_account.inc(3683) : error 017: undefined symbol "mysql_num_rows"
C:\Users\BRANDON\Desktop\CnR Server 0.3z\pawno\include\acnr_account.inc(3692) : error 017: undefined symbol "mysql_free_result"
C:\Users\BRANDON\Desktop\CnR Server 0.3z\pawno\include\acnr_account.inc(3696) : error 017: undefined symbol "mysql_store_result"
Reply
#7

Quote:
Originally Posted by Admigo
Посмотреть сообщение
and what about:
Код:
C:\Users\BRANDON\Desktop\CnR Server 0.3z\pawno\include\acnr_account.inc(3683) : error 017: undefined symbol "mysql_num_rows"
C:\Users\BRANDON\Desktop\CnR Server 0.3z\pawno\include\acnr_account.inc(3692) : error 017: undefined symbol "mysql_free_result"
C:\Users\BRANDON\Desktop\CnR Server 0.3z\pawno\include\acnr_account.inc(3696) : error 017: undefined symbol "mysql_store_result"
Old function of mysql was unsupported since R8+, I suggest you to use threading queries and caches, Its more easiest, here is the tutorial https://sampforum.blast.hk/showthread.php?tid=337810
Reply
#8

Quote:
Originally Posted by Kiyozi_Mu
Посмотреть сообщение
Old function of mysql was unsupported since R8+, I suggest you to use threading queries and caches, Its more easiest, here is the tutorial https://sampforum.blast.hk/showthread.php?tid=337810
I already used threaded queries like:
Код:
mysql_query(globalstring, _THREAD_SAVE_PLAYER, 0, gSQL);//query
Now i need to convert those codes to?
Reply
#9

Quote:
Originally Posted by Admigo
Посмотреть сообщение
I already used threaded queries like:
Код:
mysql_query(globalstring, _THREAD_SAVE_PLAYER, 0, gSQL);//query
Now i need to convert those codes to?
I mean, cache function, check it out: https://sampforum.blast.hk/showthread.php?tid=337810
Reply
#10

Quote:
Originally Posted by Kiyozi_Mu
Посмотреть сообщение
I mean, cache function, check it out: https://sampforum.blast.hk/showthread.php?tid=337810
Okay thanks, i will try it out. Will take some time to convert all stuff.
Other question:
I dont need to use mysql_store_result() and mysql_free_result() anymore like in this code:
pawn Код:
mysql_store_result();
            if(mysql_num_rows(gSQL) > 0)
            {
               
                mysql_fetch_row_format(resultline);

                if(sscanf(resultline, "p<|>dddddddddddddddddddddddddddd",
                    PlayerInfo[extraid][pWeapon1],
                    PlayerInfo[extraid][pWeapon1Ammo],
                    PlayerInfo[extraid][pWeapon2],
                    PlayerInfo[extraid][pWeapon2Ammo],
                    PlayerInfo[extraid][pWeapon3],
                    PlayerInfo[extraid][pWeapon3Ammo],
                    PlayerInfo[extraid][pWeapon4],
                    PlayerInfo[extraid][pWeapon4Ammo],
                    PlayerInfo[extraid][pWeapon5],
                    PlayerInfo[extraid][pWeapon5Ammo],
                    PlayerInfo[extraid][pWeapon6],
                    PlayerInfo[extraid][pWeapon6Ammo],
                    PlayerInfo[extraid][pWeapon7],
                    PlayerInfo[extraid][pWeapon7Ammo],
                    PlayerInfo[extraid][pWeapon8],
                    PlayerInfo[extraid][pWeapon8Ammo],
                    PlayerInfo[extraid][pWeapon9],
                    PlayerInfo[extraid][pWeapon9Ammo],
                    PlayerInfo[extraid][pWeapon10],
                    PlayerInfo[extraid][pWeapon10Ammo],
                    PlayerInfo[extraid][pWeapon11],
                    PlayerInfo[extraid][pWeapon11Ammo],
                    PlayerInfo[extraid][pWeapon12],
                    PlayerInfo[extraid][pWeapon12Ammo],
                    PlayerInfo[extraid][pCarSlots],
                    PlayerInfo[extraid][pBoatSlots],
                    PlayerInfo[extraid][pHeliSlots],
                    PlayerInfo[extraid][pPlaneSlots]))
                    {
                        //SendClientMessage(extraid, LIGHT_GREEN, "There was a problem while loading your account");
                        //KickEx(extraid);
                        mysql_free_result();
                        return 1;
                    }
            }
            mysql_free_result();
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)