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=487713)



mysql - MatriXgaMer - 14.01.2014

i got this error:
Код:
[22:37:10] [ERROR] CMySQLQuery::Execute[()] - (error #1064) You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '0')' at line 1
but its showing only line 1 but my line one is include <a_samp>
i used this tutorial from @FireCat and its not saving player stats because of this.


Re: mysql - BullseyeHawk - 14.01.2014

When it says, "at line 1" it dosen't actually mean PAWNO line 1.

Please list all of your mysql_query operations in your gamemode/filterscript so we could analyze them.
I am not sure about the correct fix for the error as you presented it, cause I have no idea whats the line and how it ends. But I guess its an UPDATE or INSERT exceute query.


Re: mysql - MatriXgaMer - 14.01.2014

Query 1:
pawn Код:
public OnPlayerConnect(playerid)
{
    new Query[80],pName[24],string[164];
    GetPlayerName(playerid,pName,24);
    format(Query,sizeof(Query),"SELECT `Ime` FROM `igraci` WHERE `Ime` = '%s' LIMIT 1;",pName);
    mysql_query(konekcija, Query, false);
    mysql_store_result();
    if(mysql_num_rows() != 0)
    {
    format(string,sizeof(string),"Dobro dosao na Country Life RolePlay.\n"BELA"|Account| Postoji.\n"BELA"Upisite vas password da se logujete.");
    ShowPlayerDialog(playerid,0,DIALOG_STYLE_INPUT,"Login",string,"Login","");
    }
    else
    {
    format(string,sizeof(string),"Dobro dosao na Country Life RolePlay.\n"BELA"|Account| Nemate.\nUpisite password po zelji radi registracije!",pName);
    ShowPlayerDialog(playerid,1,DIALOG_STYLE_INPUT,"Register",string,"Register","");
    }
    mysql_free_result(0);
    return 1;
}
Query 2:
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    new pName[MAX_PLAYER_NAME];
    GetPlayerName(playerid, pName, sizeof(pName));
    if(dialogid == 1)
    {
    if(strlen(inputtext) == 0)
    {
    ShowPlayerDialog(playerid,1,DIALOG_STYLE_INPUT,"Register","Dobro dosao na Country Life RolePlay.\n"BELA"|Account| Nemate.\nUpisite password po zelji radi registracije!", "Register", "");
    }
    else
    {
    new EscapedText[60], Query[200], poruka[128];
    mysql_real_escape_string(inputtext, EscapedText);
    format(Query,sizeof(Query),"INSERT INTO `Users` (Username,Password,Money) VALUES ('%s','%s,'0')",pName,EscapedText);
    mysql_query(konekcija, Query, false);
    format(poruka, sizeof(poruka), ""SVETLOSMEDJA"[CL:RP]:"BELA" (( Uspesno ste se registrovali sa imenom %s i sa sifrom %s. ))", imeigraca(playerid), inputtext);
    SendClientMessage(playerid, -1, poruka);
    GivePlayerMoney(playerid,5000);
    SetPlayerScore(playerid,1);
    }
    }
    if(dialogid == 2)
    {
    if(strlen(inputtext) == 0)
    {
    ShowPlayerDialog(playerid,1,DIALOG_STYLE_INPUT,"Register","Dobro dosao na Country Life RolePlay.\n"BELA"|Account| Nemate.\nUpisite password po zelji radi registracije!", "Register", "");
    }
    else
    {
    LoginPlayer(playerid,inputtext);
    }
    }
    return 1;
}
Query 3:
pawn Код:
stock LoginPlayer(playerid,const password[])
{
    new EscapedText[60], Query[200];
    mysql_real_escape_string(password, EscapedText);
    format(Query,sizeof(Query),"SELECT * FROM `igrac` WHERE `Ime` = '%s' AND `Lozinka` = '%s'",imeigraca(playerid),EscapedText);
    mysql_query(konekcija, Query, false);
    mysql_store_result();
    if(mysql_num_rows() != 0)
    {
    SendClientMessage(playerid,-1,""SVETLOSMEDJA"[CL:RP]:"BELA" (( Uspesan login. ))");
    LoadStats(playerid);
    }
    else
    {
    SendClientMessage(playerid,-1,""SVETLOSMEDJA"[CL:RP]:"BELA" (( Pogresan password. ))");
    Kick(playerid);
    }
    mysql_free_result(0);
    return 1;
}
Query 4:
pawn Код:
stock LoadStats(playerid)
{
    new pName[24],Query[80];
    GetPlayerName(playerid,pName,24);
    format(Query, sizeof(Query), "SELECT * FROM `igrac` WHERE `Ime` = '%s' ", pName);
    mysql_query(konekcija, Query, false);
    mysql_store_result();
    mysql_fetch_row_format(Query, "|");
    sscanf(Query, "e<p<|>s[24]s[23]i>", pInfo[playerid]);
    mysql_free_result(0);
    GivePlayerMoney(playerid,pInfo[playerid][Novac]);
    return 1;
}
Sorry for giving the full code


Re: mysql - BullseyeHawk - 14.01.2014

Common mistake when you're typing too fast, at query 2.

Код:
format(Query,sizeof(Query),"INSERT INTO `Users` (Username,Password,Money) VALUES ('%s','%s,'0')",pName,EscapedText);
You forgot a ' that closes the %s.

Fixed:
Код:
format(Query,sizeof(Query),"INSERT INTO `Users` (Username,Password,Money) VALUES ('%s','%s','0')",pName,EscapedText);



Re: mysql - MatriXgaMer - 14.01.2014

Quote:
Originally Posted by BullseyeHawk
Посмотреть сообщение
Common mistake when you're typing too fast, at query 2.

Код:
format(Query,sizeof(Query),"INSERT INTO `Users` (Username,Password,Money) VALUES ('%s','%s,'0')",pName,EscapedText);
You forgot a ' that closes the %s.

Fixed:
Код:
format(Query,sizeof(Query),"INSERT INTO `Users` (Username,Password,Money) VALUES ('%s','%s','0')",pName,EscapedText);
Ahh dude you just made my Night !


Re: mysql - MatriXgaMer - 14.01.2014

Ohh i now got no errors but
Код:
[22:58:07] [WARNING] cache_get_row_count - no active cache
and i register and it put me in the table 'igraci' but i join again and i need again to register using @CarFire's register and login tutorial


Re: mysql - BullseyeHawk - 14.01.2014

Quote:
Originally Posted by MatriXgaMer
Посмотреть сообщение
Ohh i now got no errors but
Код:
[22:58:07] [WARNING] cache_get_row_count - no active cache
and i register and it put me in the table 'igraci' but i join again and i need again to register using @CarFire's register and login tutorial
Got absolutly no idea why you're using the active cache. I am not a professional mysql scripter, but this just looks a big waist of time. The most basic things you need to withdraw or insert things into mysql are mysql_query.
Try to read about some information at the mysql sa-mp wiki.

Try using mysql_query, mysql_store_result, mysql_retrieve_row, mysql_fetch_field_row from the WIKI page.
I am not going to write it down for you, cause I want you to learn as well.

https://sampwiki.blast.hk/wiki/MySQL