MySQL Account save problem
#1

Hello, I started using a MySQL based script and I've been facing some problems, I'd appreciate if someone could help me
I have a problem in the account save (login system). When I register a new account, I log-out, relog again and it says "Please register a new account". Basically the account does not save when I logout.

PS: this problem occurs only in my Linux VPS, it works perfectly in Windows.

This is the .sql file: https://pastebin.com/ZajiAsgQ

This is taken from mysql_log.txt

Код:
[05:05:36 08/08/17] [ERROR] CMySQLQuery::Execute[] - (error #1364) Field 'Level' doesn't have a default value (Query: "INSERT INTO `players` (`Name`, `Key_`) VALUES('Clark_Peter', 'cncr‡OPO')")
[05:05:36 08/08/17] [ERROR] CMySQLResult::GetRowDataByName() - invalid row index ('0') (Query: "SELECT `ID` FROM `players` WHERE `name` = 'Clark_Peter' LIMIT 1")
[05:05:36 08/08/17] [ERROR] cache_get_field_content_int - invalid datatype
[05:10:33 08/08/17] [WARNING] CMySQLHandle::DeleteSavedResult - invalid result id ('0')
[05:11:21 08/08/17] [ERROR] CMySQLQuery::Execute[] - (error #1364) Field 'AdminLvl' doesn't have a default value (Query: "INSERT INTO `players` (`Name`, `Key_`) VALUES('Clark_Peter', 'fwek‘‚“‰є»НЛ)')")
[05:11:21 08/08/17] [ERROR] CMySQLResult::GetRowDataByName() - invalid row index ('0') (Query: "SELECT `ID` FROM `players` WHERE `name` = 'Clark_Peter' LIMIT 1")
[05:11:21 08/08/17] [ERROR] cache_get_field_content_int - invalid datatype
[05:11:32 08/08/17] [WARNING] CMySQLHandle::DeleteSavedResult - invalid result id ('0')
[05:18:05 08/08/17] [ERROR] CMySQLQuery::Execute[] - (error #1364) Field 'AdminLvl' doesn't have a default value (Query: "INSERT INTO `players` (`Name`, `Key_`) VALUES('Clark_Peter', '1;85P`‡€№Ж')")
[05:18:05 08/08/17] [ERROR] CMySQLResult::GetRowDataByName() - invalid row index ('0') (Query: "SELECT `ID` FROM `players` WHERE `name` = 'Clark_Peter' LIMIT 1")
[05:18:05 08/08/17] [ERROR] cache_get_field_content_int - invalid datatype
[05:18:05 08/08/17] [WARNING] CMySQLHandle::DeleteSavedResult - invalid result id ('0')
[05:18:50 08/08/17] [ERROR] CMySQLQuery::Execute[] - (error #1364) Field 'AdminLvl' doesn't have a default value (Query: "INSERT INTO `players` (`Name`, `Key_`) VALUES('Clark_Peter', 'hgnl‹•ЌЋДѕ‹‰е')")
[05:18:50 08/08/17] [ERROR] CMySQLResult::GetRowDataByName() - invalid row index ('0') (Query: "SELECT `ID` FROM `players` WHERE `name` = 'Clark_Peter' LIMIT 1")
[05:18:50 08/08/17] [ERROR] cache_get_field_content_int - invalid datatype
[05:20:42 08/08/17] [WARNING] CMySQLHandle::DeleteSavedResult - invalid result id ('0')
[05:21:25 08/08/17] [WARNING] CMySQLHandle::DeleteSavedResult - invalid result id ('0')
This is taken from server_logs.txt

Код:
[05:18:38] [join] Clark_Peter has joined the server (0:**.92.80.155)
[05:18:44] mysql_tquery OnPlayerRequestClass
[05:18:50] mysql_tquery OnPlayerRegister
[05:18:50] Account created for Clark_Peter
[05:18:50] [MySQL] SQLSave(start) Clark_Peter.
[05:18:50] [MySQL] SQLSave(end) Clark_Peter.
[05:18:50] mysql_tquery SetPlayerID
[05:18:50] OnQueryError: errorid: 1364, error: Field 'AdminLvl' doesn't have a default value, callback: , query: INSERT INTO `players` (`Name`, `Key_`) VALUES('Clark_Peter', 'hgnl‹•ЌЋДѕ‹‰е'), connectionHandle: 1
[05:18:50] SetPlayerID: Clark_Peter - BEFORE: 0 | AFTER: 0

[05:20:42] [MySQL] SQLSave(start) Clark_Peter.
[05:20:42] [MySQL] SQLSave(end) Clark_Peter.

[05:20:42] [part] Clark_Peter has left the server (0:1)
[05:21:11] [connection] **.**.6.239:33176 requests connection cookie.
[05:21:12] [connection] incoming connection: **.**.6.239:33176 id: 0

[05:21:12] [join] Clark_Peter has joined the server (0:**.**.6.239)

[05:21:16] [HouseInfo] 0 houses were saved.
[05:21:16] mysql_tquery SaveStuff
[05:21:18] mysql_tquery OnPlayerRequestClass

[05:21:25] [part] Clark_Peter has left the server (0:2)
Please help me, I really need this fixed as soon as possible. Tell me if I have to provide anything else, thanks.
Reply
#2

Errors are due to the field in MySQL not having a default value (what is inserted if you do not specify any value).

Either specify a value for those fields in your query, or set a default value.
Reply
#3

But why it works fine in windows ?
Reply
#4

It probably isn't a Windows vs Linux thing, rather it is the configuration of the specific MySQL server.
Reply
#5

On your Windows machine, can you execute:
PHP код:
SHOW CREATE TABLE players
If the output of that query does show default values then your table setup is different.

Also that SQL script is horribly unoptimized. A single table shouldn't contain more than 30 fields or so, much less 300. That whole "accessory" section especially can and should be moved to a different table that has 13 columns rather than 84. Each new accessory constitutes a new row, not a new set of columns. Same thing with guns, licenses, times, inventory item, bans and whatever.
Reply
#6

Quote:
Originally Posted by Storm94
Посмотреть сообщение
It probably isn't a Windows vs Linux thing, rather it is the configuration of the specific MySQL server.
Quote:
Originally Posted by Vince
Посмотреть сообщение
On your Windows machine, can you execute:
PHP код:
SHOW CREATE TABLE players
If the output of that query does show default values then your table setup is different.

Also that SQL script is horribly unoptimized. A single table shouldn't contain more than 30 fields or so, much less 300. That whole "accessory" section especially can and should be moved to a different table that has 13 columns rather than 84. Each new accessory constitutes a new row, not a new set of columns. Same thing with guns, licenses, times, inventory item, bans and whatever.
Quote:
Originally Posted by Storm94
Посмотреть сообщение
It probably isn't a Windows vs Linux thing, rather it is the configuration of the specific MySQL server.
Alright thanks men, but can you show me how can I properly set a default value or do it for me please? bacause and I tried adding NOT NULL DEFAULT ‘0’ but it gives me error.

Also, shall I set it for every field or what?
Reply
#7

Someone help me please? I can give him access to my server files to solve it for me. I'd appreciate that.
Reply
#8

Actually I fixed the problem by setting default values to all of them. But I've another problem now, when I register the server crashes, but the account is registered in the database.

When I turn on the server again, I log back with it, everything seems to work just fine. Now the problem is filonly in registration.




Код:
[20:08:36 08/09/17] [ERROR] CMySQLResult::GetRowDataByName() - invalid row index ('0') (Query: "SELECT `ID` FROM `players` WHERE `name` = 'Mark_Banger' LIMIT 1")
[20:08:36 08/09/17] [ERROR] cache_get_field_content_int - invalid datatype
[20:08:58 08/09/17] [WARNING] CMySQLHandle::DeleteSavedResult - invalid result id ('0')
This is from the server script:
Код:
SQLSave(playerid);
		mysql_format(sqlGameConnection, saveQuery, sizeof(saveQuery), "SELECT `ID` FROM `players` WHERE `name` = '%e' LIMIT 1", PlayerName(playerid));
		mysql_tquery(sqlGameConnection, saveQuery, "SetPlayerID", "d", playerid);
		printf("mysql_tquery SetPlayerID");
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)