SA-MP Forums Archive
MySQL - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: MySQL (/showthread.php?tid=501778)



MySQL - MythicalMarauder - 20.03.2014

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:
pawn Код:
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!


Re: MySQL - Sascha - 20.03.2014

pawn Код:
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)


Re: MySQL - MythicalMarauder - 20.03.2014

Quote:
Originally Posted by Sascha
Посмотреть сообщение
pawn Код:
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.


Re: MySQL - Sascha - 20.03.2014

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.


Re: MySQL - MythicalMarauder - 20.03.2014

[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 ..


Re: MySQL - Sascha - 20.03.2014

yea, you are not even connected to your mysql DB. then a query can't work ofc...
show us your mysql_connect


Re: MySQL - MythicalMarauder - 20.03.2014

pawn Код:
mysql_connect("37.59.28.180","lethal_1800","lethal_1800",""); // pass hidden :3



AW: MySQL - Macronix - 20.03.2014

Have you tried using "localhost" instead of "37.59.28.180" ?


Re: MySQL - Sascha - 20.03.2014

in case that you are connecting to a remote database, you should check whether it is allowing remoteaccess..


Re: MySQL - MythicalMarauder - 20.03.2014

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.