Car remont.
#1

Hi visitors,i have on question,with that code:

Код:
stock IsRemont(playerid)
{
new Query [ 100 ];
format( Query,sizeof( Query ),"SELECT * FROM `RemontCars` WHERE `Owner` = '%s'",PlayerName(playerid));
mysql_query( Query );
mysql_store_result( );
if( mysql_num_rows( )==0 )
{
PlayerData[ playerid ][ Remont] = 0;
}
else if(mysql_num_rows( ) !=0 )
{
PlayerData[ playerid ][ Remont] = 1;
}
mysql_free_result( );
}
And then after onplayerdisconnect:

Код:
IsRemont(playerid);
format(Query, sizeof(Query),"UPDATE `playerdata` SET `Remont` = '%d' WHERE `Name` = '%s'",PlayerData[playerid][Remont],PlayerName(playerid));
mysql_query(Query);
What i want to do here?I want to do,if player car need remont,then it will save 1 other 0. All is good,all save,but when i load it:

Код:
mysql_fetch_field_row( savingstring, "Remont"); PlayerData[ playerid ][ Remont] = strval(savingstring);
And it no load.I check log,and i see that:

Код:
[10:19:52] >> mysql_fetch_field_row( Connection handle: 1 )

[10:19:52] CMySQLHandler::FetchField("Remont") -
How you see,here is no number...
Reply
#2

If "`Remont` = '%d'" is not meant to be a string then make it "`Remont` = %d"
Reply
#3

Fixed. Anyway thanks for try helping.Now other problem with mysql formating:

format(QueryS, sizeof(QueryS),"SELECT * FROM RemontCars WHERE Owner= '%s'",PlayerName(playerid));

And i get error in log:

Код:
[11:30:11] CMySQLHandler::Query(SELECT * FROM RemontCars WHERE Owner` = 'Nestea') - An error has occured. (Error ID: 1064, You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '` = 'Nestea'' at line 1)
Reply
#4

Quote:
Originally Posted by budelis
Посмотреть сообщение
Fixed. Anyway thanks for try helping.Now other problem with mysql formating:

format(QueryS, sizeof(QueryS),"SELECT * FROM RemontCars WHERE Owner= '%s'",PlayerName(playerid));

And i get error in log:

Код:
[11:30:11] CMySQLHandler::Query(SELECT * FROM RemontCars WHERE Owner` = 'Nestea') - An error has occured. (Error ID: 1064, You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '` = 'Nestea'' at line 1)
Shouldn't the RemontCars be between ' and ' as its string? I don't know much about sql but i guess this is the mistake.

format(QueryS, sizeof(QueryS),"SELECT * FROM 'RemontCars' WHERE Owner= '%s'",PlayerName(playerid));
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)