Mysql p
#1

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);
Reply
#2

Sorry for bumping, but i need an solution. +REP if helped.
Reply
#3

From the SA-MP Wiki:
PHP код:
new MySQL:sql;
// ...
public OnGameModeInit()
{
    
sql mysql_connect("server""root""mypass""mydatabase");
    
// ...
    
return 1;

Reply
#4

It does not work as expected. Anyone else ?
Reply
#5

PHP код:
handle mysql_init(LOG_ONLY_ERRORS1); 
The thread shows that printerrors are by default 1, however, in the Wiki page it says otherwise.
Reply
#6

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. *
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)