PDA

View Full Version : MySQL issue


Scofield11
30/05/2018, 08:35 AM
Hey guys, I've been recently looking forward to use a pre-scripted gamemode that uses MySQL, I have managed to edit bunch of things and fix some of the errors but I'm still experiencing an issue when registering a new account.

So basically at first it used to give me these two errors, but I fixed them:
[08:11:37 05/30/18] [ERROR] CMySQLQuery::Execute[] - (error #1060) Duplicate column name 'SpawnPos' (Query: "ALTER TABLE `players` ADD `SpawnPos` INT NOT NULL DEFAULT '0';")
[08:11:37 05/30/18] [ERROR] CMySQLQuery::Execute[] - (error #1060) Duplicate column name 'LogUnix' (Query: "ALTER TABLE `players` ADD `LogUnix` INT NOT NULL DEFAULT '0';")
[08:11:37 05/30/18] [ERROR] CMySQLQuery::Execute[] - (error #1060) Duplicate column name 'HelperReports' (Query: "ALTER TABLE `players` ADD `HelperReports` INT NOT NULL DEFAULT '0';")
[08:11:37 05/30/18] [ERROR] CMySQLQuery::Execute[] - (error #1060) Duplicate column name 'family' (Query: "ALTER TABLE `vehicles` ADD `family` INT(2) NOT NULL DEFAULT 0;")
[08:11:37 05/30/18] [ERROR] CMySQLQuery::Execute[] - (error #1060) Duplicate column name 'lockfeature' (Query: "ALTER TABLE `vehicles` ADD `lockfeature` INT(2) NOT NULL DEFAULT 0;")

Everytime it gave me one of these errors, but I got them fixed.
[ERROR] CMySQLResult::GetRowDataByName() - invalid row index ('0') (Query: "SELECT HouseID FROM houses ORDER BY HouseID DESC LIMIT 1;")
[ERROR] cache_get_field_content_int - invalid datatype
[ERROR] CMySQLResult::GetRowDataByName() - invalid row index ('0') (Query: "SELECT * FROM `stuff`")
[ERROR] cache_get_field_content_int - invalid datatype
[ERROR] CMySQLResult::GetRowDataByName() - invalid row index ('0') (Query: "SELECT HouseID FROM houses ORDER BY HouseID DESC LIMIT 1;")
[ERROR] cache_get_field_content_int - invalid datatype
[WARNING] CMySQLHandle::DeleteSavedResult - invalid result id ('0')
[ERROR] CMySQLResult::GetRowDataByName() - invalid row index ('0') (Query: "SELECT * FROM `stuff`")
[ERROR] cache_get_field_content_int - invalid datatype
[ERROR] CMySQLResult::GetRowDataByName() - invalid row index ('0') (Query: "SELECT HouseID FROM houses ORDER BY HouseID DESC LIMIT 1;")
[ERROR] cache_get_field_content_int - invalid datatype
[WARNING] CMySQLHandle::DeleteSavedResult - invalid result id ('1')
[ERROR] CMySQLResult::GetRowDataByName() - invalid row index ('0') (Query: "SELECT `versionstr` FROM `stuff`")


But, now whenever I try to create a new account, I type the password then the server crashes and I have to restart it again. But the account then is successfully registered into the database. I'm pretty sure there's something wrong with the 'houses' table but I'm unable to locate the error, so please help me to do so.

Here's the .sql file: https://pastebin.com/xFPTbXSy
Here's the (loading owned/unowned houses): https://pastebin.com/00F1X7M2
Here's the server_log:
[08:50:10] [connection] incoming connection: 127.0.0.1:51133 id: 0
[08:50:10] [join] Hello_World has joined the server (0:127.0.0.1)
[08:50:15] mysql_tquery OnPlayerRequestClass
[08:50:23] mysql_tquery OnPlayerRegister
[08:50:23] Account created for Hello_World
[08:50:23] [MySQL] SQLSave(start) Hello_World.
[08:50:23] [MySQL] SQLSave(end) Hello_World.
[08:50:23] mysql_tquery SetPlayerID

Thank you <3

GTLS
30/05/2018, 09:19 AM
First Errors came, because you already had those columns in your DB but you still tried to add them.

Second errors came because Query is set to give output even if there are no houses in table.

add, if(cache_num_rows()) before loading to make sure it loads only if rows are there else, not.

Also, Rows start from 0 index and your for loop in Loading houses starts from 1.

for(new id = 1; id < cache_num_rows(); id++)
Set it to,
for(new id = 0; id < cache_num_rows(); id++)

Scofield11
30/05/2018, 09:54 AM
I did what you said but the crash still remains, and I'm getting now this error instead.

[09:40:51 05/30/18] [WARNING] cache_get_row_count - no active cache

GTLS
30/05/2018, 10:35 AM
Cache is not active means, the mysql_tquery was not initiated to create a cache memory. Put Debugging statement like, print("Cache Created"); inside MySQL Threaded function to see if it gets called or not.

Scofield11
31/05/2018, 01:05 AM
I had an issue with the 'ID' collumn and I fixed it, but I'm still experiencing the crash. Do you have any idea how can I get this error fixed?

[00:58:19 05/31/18] [WARNING] cache_get_row_count - no active cache

GTLS
31/05/2018, 06:07 AM
Cache is not active means, the mysql_tquery was not initiated to create a cache memory. Put Debugging statement like, print("Cache Created"); inside MySQL Threaded function to see if it gets called or not.

By Doing this.