Jump to content

Question

Posted

Am erorile astea in mysql log. 

[12:11:18 07/27/18] [ERROR] CMySQLQuery::Execute[insertAccount] - (error #1064) You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ''users' ('Name', 'Password') VALUES ('rAcs', 'test1234')' at line 1 (Query: "INSERT INTO 'users' ('Name', 'Password') VALUES ('rAcs', 'test1234')")
[12:11:23 07/27/18] [ERROR] CMySQLQuery::Execute[] - (error #1064) You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ''users' SET 'Email'='[email protected]' WHERE 'ID'='0'' at line 1 (Query: "UPDATE 'users' SET 'Email'='[email protected]' WHERE 'ID'='0'")
[12:11:25 07/27/18] [ERROR] CMySQLQuery::Execute[] - (error #1064) You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ''users' SET 'Gender'='0' WHERE 'ID'='0'' at line 1 (Query: "UPDATE 'users' SET 'Gender'='0' WHERE 'ID'='0'")

Ce ar trebui sa fac?

Au legatura cu liniile astea?

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) {
	switch(dialogid) {
		case DIALOG_REGISTER: {
			if(!response)
				return Kick(playerid);

			if (strlen(inputtext) < 6 || strlen(inputtext) > 32)
				return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "Register", "Scrie o parola pentru a te putea inregistra (minim 6 caractere / maxim 32):", "Select", "Cancel");

			gQuery[0] = EOS;
			mysql_format(SQL, gQuery, sizeof(gQuery), "INSERT INTO 'users' ('Name', 'Password') VALUES ('%s', '%s')", GetName(playerid), inputtext);
			mysql_tquery(SQL, gQuery, "insertAccount", "i" , playerid);

			gString[0] = EOS;
			format(gString, sizeof(gString), "Parola ta contine %d caractere.", strlen(inputtext));
			SCM(playerid, -1, gString);

			format(PlayerInfo[playerid][pPassword], 32, inputtext);

			ShowPlayerDialog(playerid, DIALOG_EMAIL, DIALOG_STYLE_INPUT, "Email", "Seteaza-ti adresa de email:", "Select", "Cancel");
		}
		case DIALOG_EMAIL: {
			if(!response)
				return Kick(playerid);

			if (strlen(inputtext) < 6 || strlen(inputtext) > 32)
				return ShowPlayerDialog(playerid, DIALOG_EMAIL, DIALOG_STYLE_INPUT, "Email", "Seteaza-ti adresa de email:", "Select", "Cancel");

			gQuery[0] = EOS;
			mysql_format(SQL, gQuery, sizeof(gQuery), "UPDATE 'users' SET 'Email'='%s' WHERE 'ID'='%d'", inputtext, PlayerInfo[playerid][pSQLID]);
			mysql_tquery(SQL, gQuery, "", "");

			gString[0] = EOS;
			format(gString, sizeof(gString), "Email setat: %s", inputtext);
			SCM(playerid, -1, gString);

			format(PlayerInfo[playerid][pEmail], 32, inputtext);

			ShowPlayerDialog(playerid, DIALOG_GENDER, DIALOG_STYLE_MSGBOX, "Gender", "Seteaza-ti sexul:", "Masculin", "Feminin");
		}
		case DIALOG_GENDER: {
			switch(response) {
				case 0: {
					PlayerInfo[playerid][pGender] = 1;
					SCM(playerid, -1, "Sex setat: Feminin");
				}
				case 1: {
					PlayerInfo[playerid][pGender] = 0;
					SCM(playerid, -1, "Sex setat: Masculin");
				}
			}

			gQuery[0] = EOS;
			mysql_format(SQL, gQuery, sizeof(gQuery), "UPDATE 'users' SET 'Gender'='%d' WHERE 'ID'='%d'", PlayerInfo[playerid][pGender], PlayerInfo[playerid][pSQLID]);
			mysql_tquery(SQL, gQuery, "", "");

			SpawnPlayer(playerid);
		}

Sau au legatura cu xampp?

4 answers to this question

Recommended Posts

  • 0
Posted

Trebuie sa folosesti ` (backtick) pentru a semnala ca respectivu lucru este un tabel/coloaona, nu apostrof. De asemenea functioneaza si fara dar in cazul in care coloana e de fapt un keyword de la mysql s-ar putea sa nu mearga

mysql_format(SQL, gQuery, sizeof(gQuery), "UPDATE `users` SET `Gender` = %d WHERE `ID` = %d", PlayerInfo[playerid][pGender], PlayerInfo[playerid][pSQLID]);
		

Deasemenea nu pune acel singur apostrof la %d %i %f nu ai nevoie + reduce din viteza de procesare a query-ului. Acel singur apostrof trebuie pus numa la '%s' '%e' pentru ca astea sunt stringuri

  • Like 1
  • 0
Posted (edited)
2 hours ago, Banditul said:

Trebuie sa folosesti ` (backtick) pentru a semnala ca respectivu lucru este un tabel/coloaona, nu apostrof. De asemenea functioneaza si fara dar in cazul in care coloana e de fapt un keyword de la mysql s-ar putea sa nu mearga


mysql_format(SQL, gQuery, sizeof(gQuery), "UPDATE `users` SET `Gender` = %d WHERE `ID` = %d", PlayerInfo[playerid][pGender], PlayerInfo[playerid][pSQLID]);
		

Deasemenea nu pune acel singur apostrof la %d %i %f nu ai nevoie + reduce din viteza de procesare a query-ului. Acel singur apostrof trebuie pus numa la '%s' '%e' pentru ca astea sunt stringuri

Multumesc, revin cu edit daca functioneaza sau nu.

P.S, cum ai pus " ` "? 

A functionat, mersi frumos.

Edited by rAcs
  • 0
Posted
1 oră în urmă, rAcs a spus:

Multumesc, revin cu edit daca functioneaza sau nu.

P.S, cum ai pus " ` "? 

A functionat, mersi frumos.

Langa tasta 1 si deasupra la TAB si sub ESC ai o tasta cu acel backtick + tilda(tilda daca folosesti shift)

  • 0
Posted
1 minute ago, Banditul said:

Langa tasta 1 si deasupra la TAB si sub ESC ai o tasta cu acel backtick + tilda(tilda daca folosesti shift)

Gata, multumesc.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more details you can also review our Terms of Use and Privacy Policy.