MySQL, need help ! Big problem.
#1

I decide to create a ban system, withou using Ban( ); function.

I created the MySQL Database:
Код:
mysql_query( "CREATE TABLE IF NOT EXISTS `Banlist`(`IP` TEXT, \
													   `Name` TEXT, \
													   `Reason` TEXT, \
													   `Admin` TEXT, \
													   `BanDate` TIME, \
													   `BanTime` TIME)");
After, i put this on OnPlayerConnect:
Код:
new szMessage[ 256 ];
	format( szMessage, sizeof( szMessage ), "SELECT * FROM `Banlist` WHERE `Name` = '%s'", PlayerName( playerid ) );
    mysql_query( szMessage, THREAD_CHECK_BANS_LIST, playerid );
And the OnQueryFinish callback, i put this:
Код:
public OnQueryFinish( query[ ], resultid, extraid, connectionHandle )
{
    switch( resultid )
	{
	    case THREAD_CHECK_BANS_LIST:
		{
		    mysql_store_result( );

			if ( !IsPlayerConnected( extraid ) )
				return mysql_free_result( );
				
			new
			    Field_Result[ 512 ],
			    bField[ 4 ]
			;

			if ( mysql_num_rows( ) != 0 )
			{
			    mysql_get_field( "Reason", Field_Result );
			    format( bField[ 0 ], 128, "%s", Field_Result );
			    mysql_get_field( "Admin", Field_Result );
			    format( bField[ 1 ], 128, "%s", Field_Result );
			    mysql_get_field( "BanDate", Field_Result );
			    format( bField[ 2 ], 128, "%s", Field_Result );
			    mysql_get_field( "BanTime", Field_Result );
			    format( bField[ 3 ], 128, "%s", Field_Result );

		        TextDrawShowForPlayer( extraid, Ban_Backround );
		        TextDrawShowForPlayer( extraid, Ban_Info );
		        TextDrawShowForPlayer( extraid, Ban_Message );
		        TextDrawShowForPlayer( extraid, Ban_Details_TD );
		        TextDrawShowForPlayer( extraid, Ban_Mistake );

		        TextDrawShowForPlayer( extraid, Ban_Details[ extraid ] );
		        format( gsString, sizeof( gsString ), "Banned by Administrator: %s~n~Ban Date: %s~n~Ban Time: %s~n~Ban Reason: %s", bField[ 1 ], bField[ 2 ], bField[ 3 ], bField[ 0 ] );
				TextDrawSetString( Ban_Details[ extraid ], gsString );
		        Kick( extraid );
		        return 0;
			}
		    else
			{
			    mysql_free_result( );
			    
				new
					szQuery[ 128 ],
					EscapedSQLName[ MAX_PLAYER_NAME ],
					szPlayerName[ MAX_PLAYER_NAME ]
				;
				
				GetPlayerName( extraid, szPlayerName, MAX_PLAYER_NAME );
			    mysql_real_escape_string( szPlayerName, EscapedSQLName );
				
				format( szQuery, sizeof( szQuery ), "SELECT `IP` FROM `Accounts` WHERE `Name` = '%s'", EscapedSQLName );
				mysql_query( szQuery, THREAD_CHECK_ACCOUNT_USERNAME, extraid );
			}
		}
           }
      return 1;
}
And i want to try it, i ban myself, and when i join the server, it crash . On mysql_log type's me this:
Код:
[22:59:35] >> mysql_query( Connection handle: 1 )

[22:59:35] CMySQLHandler::Query(resultID) - Threaded query with id 1 started. (Extra ID: 0)

[22:59:35] CMySQLHandler::ProcessQueryThread(SELECT `Reason`,`Admin`,`BanDate`,`BanTime`,`Name` FROM `Banlist` WHERE `Name` = 'ASASAS') - Data is getting passed to OnQueryFinish() - (Threadsafe: Yes)

[22:59:35] OnQueryFinish(1,"SELECT `Reason`,`Admin`,`BanDate`,`BanTime`,`Name` FROM `Banlist` WHERE `Name` = 'ASASAS'") - Called.

[22:59:35] >> mysql_store_result( Connection handle: 1 )

[22:59:35] CMySQLHandler::StoreResult() - Result was stored.

[22:59:35] >> mysql_num_rows( Connection handle: 1 )

[22:59:35] CMySQLHandler::NumRows() - Returned 1 row(s)

[22:59:35] >> mysql_fetch_field_row( Connection handle: 1 )
I don't know what can i do I try to repair it for 3 hours, and i got tired.

PS> Sorry my bad english
Reply
#2

Sorry for 2x post, but please help me.
Reply
#3

Lol, anyone? please, help me with this.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)