[MySQL] samp-server closing -
bskillerbr - 01.11.2009
Hello people ...
I've got a serious problem.
I'm migrating my server to MySQL more'm having some unexpected ...
When I use the command / register (register) my samp-server closes ...
Код:
if(strcmp(cmd,"/registrar", true) == 0)
{
new senha[256];
new tmp[256];
new query[256];
tmp = strtok(cmdtext, idx);
senha = tmp;
if(!strlen(tmp)) {
SendClientMessage(playerid, cor_verde,"Uso: /registrar senha");
}
else {
mysql_real_escape_string(senha, senha);
format(query, 256,"SELECT * FROM jogadores WHERE nome LIKE '%s'",PlayerName(playerid));
mysql_query(query);
new rows = mysql_num_rows();
if(!rows) {
jogador[logado][playerid] = 1;
format(query, 256, "INSERT INTO 'jogadores' VALUES(null, '%s', '%s', '%d', '%d', '%d', '%d')", PlayerName(playerid), senha, 0, 4000, 0, 0);
new qquery = mysql_query(query);
if(qquery) {
SendClientMessage(playerid, cor_azul,"Vocк acaba de ser registrado e logado");
printf("OK");
}
else printf("Error!");
}
}
return 1;
}
Anybody know what and?
Sorry for my bad English, I'm Brazilian and ****** TRANSLATOR sucks [: D]
Re: [MySQL] samp-server closing -
Sergei - 01.11.2009
Код:
format(query, 256,"SELECT * FROM `jogadores` WHERE nome = '%s'",PlayerName(playerid));
Код:
format(query, 256, "INSERT INTO `jogadores`(nome, some, someelse, ...) VALUES (NULL, '%s', '%s', %d, %d, %d, %d)", PlayerName(playerid), senha, 0, 4000, 0, 0);
You lack of general SQL knowledge. I suggest you to read some tutorials here:
http://www.w3schools.com/sql/default.asp
Re: [MySQL] samp-server closing -
bskillerbr - 01.11.2009
Код:
if(strcmp(cmd,"/registrar", true) == 0)
{
new senha[256];
new tmp[256];
new query[256];
tmp = strtok(cmdtext, idx);
senha = tmp;
if(!strlen(tmp)) {
SendClientMessage(playerid, cor_verde,"Uso: /registrar senha");
}
else {
mysql_real_escape_string(senha, senha);
format(query, 256,"SELECT * FROM jogadores WHERE nome = '%s'",PlayerName(playerid));
mysql_query(query);
new rows = mysql_num_rows();
if(rows == 0) {
jogador[logado][playerid] = 1;
format(query, 256, "INSERT INTO 'jogadores' ('id', 'nome', 'senha', 'dinheiro', 'dinheiro_banco', 'level', 'profissao') VALUES(null, '%s', '%s', '%d', '%d', '%d', '%d')", PlayerName(playerid), senha, 0, 4000, 0, 0);
new qquery = mysql_query(query);
if(qquery) {
SendClientMessage(playerid, cor_azul,"Vocк acaba de ser registrado e logado");
printf("Ok no registro");
}
else printf("Erro no registro");
} else SendClientMessage(playerid, cor_azul, "Vocк ja esta registrado");
}
return 1;
}
I made the changes you showed me, but still closing ...
MySQL Server Logs:
Код:
[08:56:08]
[08:56:08] ---------------------------
[08:56:08] MySQL Debugging activated (11/01/09)
[08:56:08] ---------------------------
[08:56:08]
[08:56:08] mysql_connect("localhost","root","fuzrpg","******");
[08:56:08] MySQL connection has been established
[08:56:42] mysql_real_escape_string(diogo); Escaped 5 characters
[08:56:42] mysql_query("SELECT * FROM jogadores WHERE nome = 'dioguitos_br'"); Return: 1
Re: [MySQL] samp-server closing -
Sergei - 01.11.2009
you need to mysql_store_result() after using SELECT query.