PDA

View Full Version : MySQL


MythicalMarauder
20/03/2014, 10:33 AM
Hi..
I have made a register command and I want to save player data in my mysql server, it is provided by triangle.gs
It doesn't save, anything.
Here's the command:

CMD:register(playerid, params[])
{
new pass[128];
if(sscanf(params, "s[128]", pass)) return SendClientMessage(playerid, RED, "[ERROR] Correct Usage: /register [password]");
{
new query[1024];
new name[128];
GetPlayerName(playerid, name, sizeof(name));
format(query, sizeof(query), "INSERT INTO `users` (`id`, `Name`, `Password`, `Kills`, `Deaths`, `Score`, `Status`, `Health`, `Armour`, `Money`, `AdminLevel`, `VIPLevel`, `TotalTime`, `RegDate`, `Banned`, `Locked`) VALUES ('%d', '%s', '%s',0,0,0,0,0,0,0,0,0,0,0,0,0",UID, name, pass);
mysql_query(query);
print(query);
SendClientMessage(playerid, WHITE, "You have successfully registered your account.");
}
return 1;
}

Please help me as soon as possible! My server needs to be public soon! :-|

Sascha
20/03/2014, 11:17 AM
format(query, sizeof(query), "INSERT INTO `users` (`id`, `Name`, `Password`, `Kills`, `Deaths`, `Score`, `Status`, `Health`, `Armour`, `Money`, `AdminLevel`, `VIPLevel`, `TotalTime`, `RegDate`, `Banned`, `Locked`) VALUES ('%d', '%s', '%s',0,0,0,0,0,0,0,0,0,0,0,0,0)",UID, name, pass);

should work with this line.
In addition I would suggest to save "AdminLevel", "VIPLevel", "TotalTime", "RegDate", etc. in mysql with a standard value of 0. Then you don't need to do it in the query, and only need to set the id the name and the password.



(and using a hash for the password wouldn't be bad either)

MythicalMarauder
20/03/2014, 11:45 AM
format(query, sizeof(query), "INSERT INTO `users` (`id`, `Name`, `Password`, `Kills`, `Deaths`, `Score`, `Status`, `Health`, `Armour`, `Money`, `AdminLevel`, `VIPLevel`, `TotalTime`, `RegDate`, `Banned`, `Locked`) VALUES ('%d', '%s', '%s',0,0,0,0,0,0,0,0,0,0,0,0,0)",UID, name, pass);

should work with this line.
In addition I would suggest to save "AdminLevel", "VIPLevel", "TotalTime", "RegDate", etc. in mysql with a standard value of 0. Then you don't need to do it in the query, and only need to set the id the name and the password.



(and using a hash for the password wouldn't be bad either)

What did you change exactly? D:

EDIT: Doesn't work.

Sascha
20/03/2014, 11:53 AM
i added a ")" at the end of your query... check out the mysql error log, or at least the server log, there should occur an error.

MythicalMarauder
20/03/2014, 12:12 PM
[15:53:21] ---------------------------

[15:53:21] MySQL Debugging activated (03/20/14)

[15:53:21] ---------------------------

[15:53:21]

[15:54:39] >> mysql_query( Connection handle: 1 )

[15:54:39] CMySQLHandler::Query() - You cannot call this function now. (Reason: Connection is dead)

[15:54:41] >> mysql_query( Connection handle: 1 )

[15:54:41] CMySQLHandler::Query() - You cannot call this function now. (Reason: Connection is dead)

[15:59:46] >> mysql_store_result( Connection handle: 1 )

[15:59:46] CMySQLHandler::StoreResult() - There is nothing to store (Reason: Connection is dead)

[15:59:46] >> mysql_num_rows( Connection handle: 1 )

[15:59:46] CMySQLHandler::NumRows() - You cannot call this function now. (Reason: Dead Connection)

[15:59:48] >> mysql_store_result( Connection handle: 1 )

[15:59:48] CMySQLHandler::StoreResult() - There is nothing to store (Reason: Connection is dead)

[15:59:48] >> mysql_num_rows( Connection handle: 1 )

[15:59:48] CMySQLHandler::NumRows() - You cannot call this function now. (Reason: Dead Connection)

I use the MySQL server provided by triangle.gs ..

Sascha
20/03/2014, 12:21 PM
yea, you are not even connected to your mysql DB. then a query can't work ofc...
show us your mysql_connect

MythicalMarauder
20/03/2014, 12:46 PM
mysql_connect("37.59.28.180","lethal_1800","lethal_1800",""); // pass hidden :3

Macronix
20/03/2014, 01:19 PM
Have you tried using "localhost" instead of "37.59.28.180" ?

Sascha
20/03/2014, 01:45 PM
in case that you are connecting to a remote database, you should check whether it is allowing remoteaccess..

MythicalMarauder
20/03/2014, 01:48 PM
I don't know shit about MySQL, and this database is provided by triangle.gs, the site I'm currently hosting my server at.
If someone can help me, add me in Skype, it is in my signature.