Проблема с сохранением статистики (Mysql) -
Stepan23 - 21.05.2012
PHP код:
stock SavePlayer(playerid)
{
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,sizeof(name));
if(!gPlayerLogged[playerid]) return 1;
format(query, sizeof( query ),"UPDATE `accounts` SET `Admin`='%d', `Tutorial`='%d',\
`Age`='%d', `Sex`='%d', `Origin`='%d', `Model`='%d', `SpanwX`='%f', `SpawnY`='%f',\
`SpawnZ`='%f', `Carkey`='%d', `Cash`='%d', `Bank`='%d', `Leader`='%d', `Member`='%d',\
`Rank`='%d', `Warns`='%d', `InvWeapon`='%d', `InvWeapon2`='%d', `InvWeapon3`='%d',\
`InvAmmo`='%d', `InvAmmo2`='%d', `InvAmmo3`='%d' WHERE `Name`='%s' LIMIT 1",
Player[playerid][pAdmin], Player[playerid][pTutorial], Player[playerid][pAge],
Player[playerid][pSex], Player[playerid][pOrigin], Player[playerid][pModel], Player[playerid][pCordX],
Player[playerid][pCordY], Player[playerid][pCordZ], Player[playerid][pCarkey], Player[playerid][pCash],
Player[playerid][pBank], Player[playerid][pLeader], Player[playerid][pMember], Player[playerid][pRank],
Player[playerid][pWarns], Player[playerid][pInvWeapon], Player[playerid][pInvWeapon2], Player[playerid][pInvWeapon3],
Player[playerid][pInvAmmo], Player[playerid][pInvAmmo2], Player[playerid][pInvAmmo3], Player[playerid][pInvAmmo3],name);
mysql_query(query), mysql_free_result();
return 1;
}
Помогите разобраться, уже что только не делал((
Re: Проблема с сохранением статистики (Mysql) -
eakwarp - 21.05.2012
Во первых mysql_free_result(); - выкинуть, здесь это не нужно.
Во вторых query - где создается? Нигде судя по всему.
В третьих, что пишет в дебаге?
Re: Проблема с сохранением статистики (Mysql) -
Stepan23 - 21.05.2012
mysql_free_result(); Выкинул
query в начале мода
Re: Проблема с сохранением статистики (Mysql) -
Alexander_Petrov - 21.05.2012
каждую переменную дописывай в strcat
Re: Проблема с сохранением статистики (Mysql) -
eakwarp - 21.05.2012
Quote:
Originally Posted by Alexander_Petrov
каждую переменную дописывай в strcat
|
Уйдите, с такими советами. Ужас.
Re: Проблема с сохранением статистики (Mysql) -
Stepan23 - 21.05.2012
2 день уже мучаюсь
Re: Проблема с сохранением статистики (Mysql) -
Stepashka - 21.05.2012
Какой размер у
query?
Re: Проблема с сохранением статистики (Mysql) -
Stepan23 - 21.05.2012
2048
Re: Проблема с сохранением статистики (Mysql) -
Stepashka - 21.05.2012
А что нам говорит дебаг?
Re: Проблема с сохранением статистики (Mysql) -
eakwarp - 21.05.2012
Quote:
Originally Posted by Stepan23
mysql_free_result(); Выкинул
query в начале мода
|
Покажите содержимое лога, и какой размер query.
Re: Проблема с сохранением статистики (Mysql) -
Stepan23 - 21.05.2012
PHP код:
[12:50:06]
[12:50:06] ---------------------------
[12:50:06] MySQL Debugging activated (05/21/12)
[12:50:06] ---------------------------
[12:50:06]
[12:50:30] >> mysql_query( Connection handle: 1 )
[12:50:30] CMySQLHandler::Query(SELECT * FROM `accounts` WHERE `Name` = 'Aleksandr_Sbnzf') - Successfully executed.
[12:50:30] >> mysql_store_result( Connection handle: 1 )
[12:50:30] CMySQLHandler::StoreResult() - Result was stored.
[12:50:30] >> mysql_fetch_row_format( Connection handle: 1 )
[12:50:32] >> mysql_query( Connection handle: 1 )
[12:50:32] CMySQLHandler::Query(INSERT INTO `accounts` (Name, Password) VALUES ('Aleksandr_Sbnzf', '23')) - Successfully executed.
[12:50:34] >> mysql_query( Connection handle: 1 )
[12:50:34] CMySQLHandler::Query(SELECT * FROM `accounts` WHERE `Name` = 'Aleksandr_Sbnzf' AND `Password` = '23') - Successfully executed.
[12:50:34] >> mysql_store_result( Connection handle: 1 )
[12:50:34] CMySQLHandler::StoreResult() - Result was stored.
[12:50:34] >> mysql_fetch_row_format( Connection handle: 1 )
[12:50:34] CMySQLHandler::FetchRow() - Return: 5|Aleksandr_Sbnzf|23|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0
[12:50:34] >> mysql_query( Connection handle: 1 )
[12:50:34] CMySQLHandler::Query(SELECT * FROM `accounts` WHERE `Name` = 'Aleksandr_Sbnzf') - Successfully executed.
[12:50:34] >> mysql_store_result( Connection handle: 1 )
[12:50:34] CMySQLHandler::StoreResult() - Result was stored.
[12:50:34] >> mysql_fetch_row_format( Connection handle: 1 )
[12:50:34] CMySQLHandler::FetchRow() - Return: 5|Aleksandr_Sbnzf|23|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0
[12:53:07] >> mysql_query( Connection handle: 1 )
[12:53:07] CMySQLHandler::Query(UPDATE `accounts` SET `Status` = 0 WHERE `Name`='Aleksandr_Sbnzf') - An error has occured. (Error ID: 1054, Unknown column 'Status' in 'field list')
[12:53:07] >> mysql_query( Connection handle: 1 )
[12:53:07] CMySQLHandler::Query(UPDATE `accounts` SET `Admin`='5', `Tutorial`='1',`Age`='47', `Sex`='1', `Origin`='1', `Model`='101', `SpanwX`='-144.803985', `SpawnY`='1211.294677',`SpawnZ`='19.735198', `Carkey`='0', `Cash`='3000000', `Bank`='0', `Leader`='0', `Member`='0',`Rank`='0', `Warns`='0', `InvWeapon`='0', `InvWeapon2`='0', `InvWeapon3`='0',`InvAmmo`='0', `InvAmmo2`='0', `InvAmmo3`='0' WHERE `Name`='' LIMIT 1) - An error has occured. (Error ID: 1054, Unknown column 'SpanwX' in 'field list')
Re: Проблема с сохранением статистики (Mysql) -
Stepashka - 21.05.2012
Так-то он тебе пишет в чем проблема, может стоит читать логи:
Код:
Unknown column 'SpanwX' in 'field list'
И у тебя условие пустое:
Код:
WHERE `Name`='' LIMIT 1
Re: Проблема с сохранением статистики (Mysql) -
eakwarp - 21.05.2012
SpanwX - опечатка.
Re: Проблема с сохранением статистики (Mysql) -
Stepan23 - 21.05.2012
Ничего не изменилось....
Re: Проблема с сохранением статистики (Mysql) -
eakwarp - 21.05.2012
Quote:
Originally Posted by Stepan23
Ничего не изменилось....
|
Что изменили, и лог.
Re: Проблема с сохранением статистики (Mysql) -
Stepan23 - 21.05.2012
Лог:
PHP код:
[13:23:40] MySQL Debugging activated (05/21/12)
[13:23:40] ---------------------------
[13:23:40]
[13:23:55] >> mysql_query( Connection handle: 1 )
[13:23:55] CMySQLHandler::Query(SELECT * FROM `accounts` WHERE `Name` = 'Aleksandr_Sbnzller') - Successfully executed.
[13:23:55] >> mysql_store_result( Connection handle: 1 )
[13:23:55] CMySQLHandler::StoreResult() - Result was stored.
[13:23:55] >> mysql_fetch_row_format( Connection handle: 1 )
[13:23:57] >> mysql_query( Connection handle: 1 )
[13:23:57] CMySQLHandler::Query(INSERT INTO `accounts` (Name, Password) VALUES ('Aleksandr_Sbnzller', '23')) - Successfully executed.
[13:23:58] >> mysql_query( Connection handle: 1 )
[13:23:58] CMySQLHandler::Query(SELECT * FROM `accounts` WHERE `Name` = 'Aleksandr_Sbnzller' AND `Password` = '23') - Successfully executed.
[13:23:58] >> mysql_store_result( Connection handle: 1 )
[13:23:58] CMySQLHandler::StoreResult() - Result was stored.
[13:23:58] >> mysql_fetch_row_format( Connection handle: 1 )
[13:23:58] CMySQLHandler::FetchRow() - Return: 8|Aleksandr_Sbnzller|23|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0
[13:23:58] >> mysql_query( Connection handle: 1 )
[13:23:58] CMySQLHandler::Query(SELECT * FROM `accounts` WHERE `Name` = 'Aleksandr_Sbnzller') - Successfully executed.
[13:23:58] >> mysql_store_result( Connection handle: 1 )
[13:23:58] CMySQLHandler::StoreResult() - Result was stored.
[13:23:58] >> mysql_fetch_row_format( Connection handle: 1 )
[13:23:58] CMySQLHandler::FetchRow() - Return: 8|Aleksandr_Sbnzller|23|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0
[13:23:58] >> mysql_query( Connection handle: 1 )
[13:23:58] CMySQLHandler::Query(UPDATE `accounts` SET `Status` = 1 WHERE `Name`='8') - Successfully executed.
[13:26:18] >> mysql_query( Connection handle: 1 )
[13:26:18] CMySQLHandler::Query(UPDATE `accounts` SET `Admin`='23', `Tutorial`='1',`Age`='47', `Sex`='1', `Origin`='1', `Model`='101', `SpawnX`='1717.698364', `SpawnY`='1422.362182',`SpawnZ`='10.640625', `Carkey`='0', `Cash`='0', `Bank`='0', `Leader`='0', `Member`='0',`Rank`='0', `Warns`='0', `InvWeapon`='0', `InvWeapon2`='0', `InvWeapon3`='0',`InvAmmo`='0', `InvAmmo2`='0', `InvAmmo3`='0' WHERE `Name`='' LIMIT 1) - Successfully executed.
[13:26:44] >> mysql_query( Connection handle: 1 )
[13:26:44] CMySQLHandler::Query(UPDATE `accounts` SET `Status` = 0 WHERE `Name`='Aleksandr_Sbnzller') - Successfully executed.
[13:26:44] >> mysql_query( Connection handle: 1 )
[13:26:44] CMySQLHandler::Query(UPDATE `accounts` SET `Admin`='5', `Tutorial`='1',`Age`='47', `Sex`='1', `Origin`='1', `Model`='101', `SpawnX`='-143.990173', `SpawnY`='1213.620483',`SpawnZ`='19.735198', `Carkey`='0', `Cash`='3000000', `Bank`='0', `Leader`='0', `Member`='0',`Rank`='0', `Warns`='0', `InvWeapon`='30', `InvWeapon2`='0', `InvWeapon3`='0',`InvAmmo`='100', `InvAmmo2`='0', `InvAmmo3`='0' WHERE `Name`='' LIMIT 1) - Successfully executed.
Изменение: SpawnX
Добавил Статус при Логине
Re: Проблема с сохранением статистики (Mysql) -
Stepan23 - 21.05.2012
Ой вот новый лог, была проблема с Name....
PHP код:
13:33:46] ---------------------------
[13:33:46] MySQL Debugging activated (05/21/12)
[13:33:46] ---------------------------
[13:33:46]
[13:33:58] >> mysql_query( Connection handle: 1 )
[13:33:58] CMySQLHandler::Query(SELECT * FROM `accounts` WHERE `Name` = 'Aleksandr_Sbnzller') - Successfully executed.
[13:33:58] >> mysql_store_result( Connection handle: 1 )
[13:33:58] CMySQLHandler::StoreResult() - Result was stored.
[13:33:58] >> mysql_fetch_row_format( Connection handle: 1 )
[13:33:58] CMySQLHandler::FetchRow() - Return: 8|Aleksandr_Sbnzller|23|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0
[13:34:05] >> mysql_query( Connection handle: 1 )
[13:34:05] CMySQLHandler::Query(SELECT * FROM `accounts` WHERE `Name` = 'Aleksandr_Sbnzller' AND `Password` = '23') - Successfully executed.
[13:34:05] >> mysql_store_result( Connection handle: 1 )
[13:34:05] CMySQLHandler::StoreResult() - Result was stored.
[13:34:05] >> mysql_fetch_row_format( Connection handle: 1 )
[13:34:05] CMySQLHandler::FetchRow() - Return: 8|Aleksandr_Sbnzller|23|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0
[13:34:05] >> mysql_query( Connection handle: 1 )
[13:34:05] CMySQLHandler::Query(SELECT * FROM `accounts` WHERE `Name` = 'Aleksandr_Sbnzller') - Successfully executed.
[13:34:05] >> mysql_store_result( Connection handle: 1 )
[13:34:05] CMySQLHandler::StoreResult() - Result was stored.
[13:34:05] >> mysql_fetch_row_format( Connection handle: 1 )
[13:34:05] CMySQLHandler::FetchRow() - Return: 8|Aleksandr_Sbnzller|23|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0
[13:34:05] >> mysql_query( Connection handle: 1 )
[13:34:05] CMySQLHandler::Query(SELECT * FROM `accounts` WHERE `Name` = 'Aleksandr_Sbnzller') - Successfully executed.
[13:36:30] >> mysql_query( Connection handle: 1 )
[13:36:30] CMySQLHandler::Query(UPDATE `accounts` SET `Admin`='23', `Tutorial`='1',`Age`='47', `Sex`='1', `Origin`='1', `Model`='101', `SpawnX`='1715.795532', `SpawnY`='1425.187500',`SpawnZ`='10.492187', `Carkey`='0', `Cash`='0', `Bank`='0', `Leader`='0', `Member`='0',`Rank`='0', `Warns`='0', `InvWeapon`='0', `InvWeapon2`='0', `InvWeapon3`='0',`InvAmmo`='0', `InvAmmo2`='0', `InvAmmo3`='0' WHERE `Name`='Aleksandr_Sbnzller' LIMIT 1) - An error has occured. (Error ID: 2014, Commands out of sync; you can't run this command now)
[13:36:43] >> mysql_query( Connection handle: 1 )
[13:36:43] CMySQLHandler::Query(UPDATE `accounts` SET `Status` = 0 WHERE `Name`='Aleksandr_Sbnzller') - An error has occured. (Error ID: 2014, Commands out of sync; you can't run this command now)
[13:36:43] >> mysql_query( Connection handle: 1 )
[13:36:43] CMySQLHandler::Query(UPDATE `accounts` SET `Admin`='5', `Tutorial`='1',`Age`='47', `Sex`='1', `Origin`='1', `Model`='101', `SpawnX`='-141.210678', `SpawnY`='1211.808105',`SpawnZ`='19.742187', `Carkey`='0', `Cash`='3000000', `Bank`='0', `Leader`='0', `Member`='0',`Rank`='0', `Warns`='0', `InvWeapon`='0', `InvWeapon2`='0', `InvWeapon3`='0',`InvAmmo`='0', `InvAmmo2`='0', `InvAmmo3`='0' WHERE `Name`='Aleksandr_Sbnzller' LIMIT 1) - An error has occured. (Error ID: 2014, Commands out of sync; you can't run this command now)
Но снова какие то ошибки.........
Re: Проблема с сохранением статистики (Mysql) -
eakwarp - 21.05.2012
Теперь у вас проблема синхронизации, видимо сервер не успел обработать предыдущий запрос к бд.
Покажите код что ли.
Re: Проблема с сохранением статистики (Mysql) -
Stepan23 - 21.05.2012
PHP код:
stock SavePlayer(playerid)
{
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,sizeof(name));
if(!gPlayerLogged[playerid]) return 1;
format(query, sizeof( query ),"UPDATE `accounts` SET `Admin`='%d', `Tutorial`='%d',\
`Age`='%d', `Sex`='%d', `Origin`='%d', `Model`='%d', `SpawnX`='%f', `SpawnY`='%f',\
`SpawnZ`='%f', `Carkey`='%d', `Cash`='%d', `Bank`='%d', `Leader`='%d', `Member`='%d',\
`Rank`='%d', `Warns`='%d', `InvWeapon`='%d', `InvWeapon2`='%d', `InvWeapon3`='%d',\
`InvAmmo`='%d', `InvAmmo2`='%d', `InvAmmo3`='%d' WHERE `Name`='%s' LIMIT 1",
Player[playerid][pAdmin], Player[playerid][pTutorial], Player[playerid][pAge],
Player[playerid][pSex], Player[playerid][pOrigin], Player[playerid][pModel], Player[playerid][pCordX],
Player[playerid][pCordY], Player[playerid][pCordZ], Player[playerid][pCarkey], Player[playerid][pCash],
Player[playerid][pBank], Player[playerid][pLeader], Player[playerid][pMember], Player[playerid][pRank],
Player[playerid][pWarns], Player[playerid][pInvWeapon], Player[playerid][pInvWeapon2], Player[playerid] [pInvWeapon3],
Player[playerid][pInvAmmo], Player[playerid][pInvAmmo2], Player[playerid][pInvAmmo3],name);
mysql_query(query);
return 1;
}
forward OnPlayerLogin(playerid,password[]);
public OnPlayerLogin(playerid,password[])
{
new name[MAX_PLAYER_NAME],result[MAX_RESULT], string[256];
GetPlayerName(playerid, name, sizeof(name));
format(query,sizeof(query), "SELECT * FROM `accounts` WHERE `Name` = '%s' AND `Password` = '%s'", name,password);
mysql_query(query);
mysql_store_result();
if(mysql_fetch_row(result))
{
format(query,sizeof(query),"SELECT * FROM `accounts` WHERE `Name` = '%s'",name);
mysql_query(query);
mysql_store_result();
if(!mysql_fetch_row(result)) return 0;
sscanf(result, "p<|>s[24]s[32]iiiiiifffiiiiiiiiiiiii", // i - ид (int), s[размер] - string, ник и пароль.
name, Player[playerid][pPass],Player[playerid][pAdmin], Player[playerid][pTutorial], Player[playerid][pAge],
Player[playerid][pSex], Player[playerid][pOrigin], Player[playerid][pModel], Player[playerid][pCordX],
Player[playerid][pCordY], Player[playerid][pCordZ], Player[playerid][pCarkey], Player[playerid][pCash],
Player[playerid][pBank], Player[playerid][pLeader], Player[playerid][pMember], Player[playerid][pRank],
Player[playerid][pWarns], Player[playerid][pInvWeapon], Player[playerid][pInvWeapon2], Player[playerid][pInvWeapon3],
Player[playerid][pInvAmmo], Player[playerid][pInvAmmo2], Player[playerid][pInvAmmo3], Player[playerid][pInvAmmo3]);
if(Player[playerid][pAdmin] > 0)
{
format(string,sizeof(string), "{ffffff}Вы вошли как администратор {03c03c}%d {ffffff}уровня.", Player[playerid][pAdmin]);
SendClientMessage(playerid,COLOR_GRAD1,string);
}
ResetPlayerMoney(playerid);
GivePlayerMoney(playerid,Player[playerid][pCash]);
gPlayerLogged[playerid] = true;
SendClientMessage(playerid,0xFF00000,"Сервер Free Life, делает Stepan23");
mysql_query(query);
SpawnPlayer(playerid);// Спавним игрока
}
return 1;
}
Что еще надо?
Re: Проблема с сохранением статистики (Mysql) -
eakwarp - 21.05.2012
format(query,sizeof(query), "SELECT * FROM `accounts` WHERE `Name` = '%s' AND `Password` = '%s'", name,password);
mysql_query(query);
mysql_store_result();
if(mysql_fetch_row(result))
{
format(query,sizeof(query),"SELECT * FROM `accounts` WHERE `Name` = '%s'",name);
mysql_query(query);
mysql_store_result();
зачем два раза?