mysql help - 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 help (
/showthread.php?tid=286784)
mysql help -
fordawinzz - 30.09.2011
why i'm getting this thing and after my server closes? this is from debug:
Код:
[18:39:28] CMySQLHandler::Query(SELECT * FROM `blabla` WHERE id='10') - Successfully executed.
[18:39:28] >> mysql_store_result( Connection handle: 1 )
[18:39:28] CMySQLHandler::StoreResult() - Result was stored.
[18:39:28] >> mysql_fetch_row_format( Connection handle: 1 )
[18:39:28] >> mysql_free_result( Connection handle: 1 )
[18:39:28] CMySQLHandler::FreeResult() - Result was successfully free'd.
[18:39:28] >> mysql_connect( )
[18:39:28] CMySQLHandler::Connect() - Connection was successful.
[18:39:28] CMySQLHandler::Connect() - Auto-Reconnect has been enabled.
[18:39:28] >> mysql_ping( Connection handle: 1 )
[18:39:28] CMySQLHandler::Ping() - Connection is still alive.
[18:39:28] >> mysql_close( Connection handle: 1 )
[18:39:28] CMySQLHandler::~CMySQLHandler() - deconstructor called.
[18:39:28] CMySQLHandler::FreeResult() - The result is already empty.
[18:39:28] CMySQLHandler::Disconnect() - Connection was closed.
I don't have disconnect anywhere..
my code:
pawn Код:
public LoadFactions( ) {
for( new i = 1; i <= MAX_FACTIONS; i++ ) {
MySQLCheckConnection( );
new string[ 256 ];
format( string, sizeof string,"SELECT * FROM `factions` WHERE id='%d'", i );
mysql_query( string );
mysql_store_result( );
new field[ 64 ], data[ 256 ];
if(mysql_fetch_row_format( data ) )
{
mysql_fetch_field_row( field, "Name" ); format( F_DATA[ i ][ FName ], 64, "%s", field );
mysql_fetch_field_row( field, "X" ); F_DATA[ i ][ Xf ] = floatstr( field );
mysql_fetch_field_row( field, "Y" ); F_DATA[ i ][ Yf ] = floatstr( field );
mysql_fetch_field_row( field, "Z" ); F_DATA[ i ][ Zf ] = floatstr( field );
mysql_fetch_field_row( field, "A" ); F_DATA[ i ][ Af ] = floatstr( field );
mysql_fetch_field_row( field, "Interior" ); F_DATA[ i ][ Interior ] = strval( field );
mysql_fetch_field_row( field, "FMoney" ); F_DATA[ i ][ FMoney ] = strval( field );
mysql_fetch_field_row( field, "FDrugs" ); F_DATA[ i ][ FDrugs ] = strval( field );
mysql_fetch_field_row( field, "FMaterials" ); F_DATA[ i ][ FMaterials ] = strval( field );
mysql_fetch_field_row( field, "FLeaderSkin" ); F_DATA[ i ][ FLeaderSkin ] = strval( field );
mysql_fetch_field_row( field, "FSkin1" ); F_DATA[ i ][ FSkin1 ] = strval( field );
mysql_fetch_field_row( field, "FSkin2" ); F_DATA[ i ][ FSkin2 ] = strval( field );
mysql_fetch_field_row( field, "FSkin3" ); F_DATA[ i ][ FSkin3 ] = strval( field );
mysql_fetch_field_row( field, "FSkin4" ); F_DATA[ i ][ FSkin4 ] = strval( field );
mysql_fetch_field_row( field, "FSkin5" ); F_DATA[ i ][ FSkin5 ] = strval( field );
}
mysql_free_result( );
printf("Faction: %d, LSKIN: %d", i, F_DATA[ i ][ FLeaderSkin ]);
}
return true;
}
Re: mysql help -
Retardedwolf - 01.10.2011
You're not showing us the whole code? In the logs, it says SELECT blahblah not factions.
Re: mysql help -
fordawinzz - 01.10.2011
hmm, yes, I don't know why I have replaced but it is factions, so.. I think it is from mysqlcheckconnection, here's it:
pawn Код:
public MySQLCheckConnection()
{
if(mysql_ping())
{
return 1;
}
else
{
print("MYSQL: Connection seems dead, retrying...");
MySQLDisconnect();
MySQLConnect(MYSQL_HOST,MYSQL_USER,MYSQL_PASS,MYSQL_DB);
if(mysql_ping()==0)
{
print("MYSQL: Reconnection successful. We can continue as normal.");
return 1;
}
else
{
print("MYSQL: Could not reconnect to server, terminating server...");
SendRconCommand("exit");
return 0;
}
}
}
Re: mysql help -
Retardedwolf - 01.10.2011
https://sampwiki.blast.hk/wiki/MySQL#mysql_ping
mysql_ping returns -1 if the connection is dead and 1 if it is alive, in your code, you're using checking if the function returns 0.
Re: mysql help -
fordawinzz - 02.10.2011
okay, replaced but same thing..
Код:
[11:21:29] >> mysql_store_result( Connection handle: 1 )
[11:21:29] CMySQLHandler::StoreResult() - Result was stored.
[11:21:29] >> mysql_fetch_row_format( Connection handle: 1 )
[11:21:29] >> mysql_free_result( Connection handle: 1 )
[11:21:29] CMySQLHandler::FreeResult() - Result was successfully free'd.
[11:21:29] >> mysql_connect( )
[11:21:29] CMySQLHandler::Connect() - Connection was successful.
[11:21:29] CMySQLHandler::Connect() - Auto-Reconnect has been enabled.
[11:21:29] >> mysql_ping( Connection handle: 1 )
[11:21:29] CMySQLHandler::Ping() - Connection is still alive.
[11:21:29] >> mysql_close( Connection handle: 1 )
[11:21:29] CMySQLHandler::~CMySQLHandler() - deconstructor called.
[11:21:29] CMySQLHandler::FreeResult() - The result is already empty.
[11:21:29] CMySQLHandler::Disconnect() - Connection was closed.