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.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.