Mysql p - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Mysql p (
/showthread.php?tid=645468)
Mysql p -
Hunud - 27.11.2017
Using strickenkid mysql
What's the problem
Код:
error 017: undefined symbol "mysql_init"
Код:
warning 213: tag mismatch
Код:
warning 202: number of arguments does not match definition
Inside plugin
Код:
native MySQL:mysql_init(logtype = LOG_ONLY_ERRORS, printerrors = 1);
Code
Код:
forward MYSQLConnection();
public MYSQLConnection()
{
new MySQL:handle;
handle = mysql_init(LOG_ONLY_ERRORS );
new connected = mysql_connect(MYSQL_HOST, MYSQL_USER, MYSQL_PASS, MYSQL_DATABASE, handle, 2);
Re: Mysql p -
Hunud - 27.11.2017
Sorry for bumping, but i need an solution. +REP if helped.
Re: Mysql p -
rfr - 27.11.2017
From the SA-MP Wiki:
PHP код:
new MySQL:sql;
// ...
public OnGameModeInit()
{
sql = mysql_connect("server", "root", "mypass", "mydatabase");
// ...
return 1;
}
Re: Mysql p -
Hunud - 27.11.2017
It does not work as expected. Anyone else ?
Re: Mysql p -
Meller - 27.11.2017
PHP код:
handle = mysql_init(LOG_ONLY_ERRORS, 1);
The thread shows that
printerrors are by default 1, however, in the Wiki page it says otherwise.
Re: Mysql p -
Daymen - 28.11.2017
If you're trying to initialize the logging system, use the following:
Код:
mysql_log( MYSQL_LOG_TYPE );
If you're trying to actually start the database, then I have the following:
Код:
public OnGameModeInit() {
new launchTime = GetTickCount();
MySQLConnect();
if(mysql_errno())
{
SendRconCommand( "hostname "GAMEMODE_HOSTNAME" | *error*" );
SetGameModeText( ""GAMEMODE_NAME" | *error*" );
return MysqlErrorMessage( INVALID_PLAYER_ID );
}
else
{
SendRconCommand( "hostname "GAMEMODE_HOSTNAME"" );
SetGameModeText( ""GAMEMODE_NAME"" );
mysql_log( MYSQL_LOG_TYPE );
printf( "-> Gamemode ("GAMEMODE_NAME") successfully launched! (%d ms)", GetTickCount() - launchTime );
}
return 1;
}
public OnGameModeExit() {
mysql_close();
return 1;
}
public MysqlErrorMessage( playerid ) {
if ( playerid == -1 )
return printf( "-> Error sending the query to the database! (Error Code: #%d)", mysql_errno() );
else {
new mysqlError[200];
format( mysqlError, sizeof( mysqlError ), "There was an issue loading your account. Please try and relog. If the issue a persists, make a report on forums." , mysql_errno() );
SendClientMessage( playerid, -1, mysqlError );
PlayerKick( playerid );
printf( "-> Error sending the query to the database! ( Error Code: #%d )", mysql_errno() );
}
return 1;
}
stock MySQLConnect() {
new connecttime = GetTickCount();
MySQL_C1 = mysql_connect( MYSQL_HOST, MYSQL_USER, MYSQL_DB, MYSQL_PASS);
if (mysql_errno()) return print("-> Connect to database '"MYSQL_DB"' has not been established.");
else printf("-> Connect to database '"MYSQL_DB"' was successfully established. (%d ms)", GetTickCount() - connecttime );
return true;
}
* Let me know if I'm missing anything for it to not throw errors. - Just quickly copied and pasted the functions I quickly reviewed. *