SA-MP Forums Archive
mysql error [+4rep] - 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 error [+4rep] (/showthread.php?tid=509837)



mysql error [+4rep] - DarkZeroX - 28.04.2014

Hello,
My error mysql for the requet

Код:
format(string, 256, "INSERT INTO `comptes` (p_nom,p_mdp,p_email,p_origine,p_inscription_id,p_sexe) VALUES (%s, %s, %s, %d, %s, %d)",name, inputtext, inscription_email[playerid],inscription_origine[playerid],returnIp(playerid),inscription_sexe[playerid]);

mysql_function_query(mysql, string, false, "", "");

[12:12:38] Passing query INSERT INTO `comptes` (p_nom,p_mdp,p_email,p_origine,p_inscription_id,p_sexe) VALUES (DarkZeroX, teste, teste@laposte.net, 1, 127.0.0.1, 1) |
Thank You

(my bad english :/)


Re: mysql error [+4rep] - Conradus - 28.04.2014

I think strings need to be in qoates in a mysql query, can you give this a try? :
pawn Код:
format(string, 256, "INSERT INTO `comptes` ('p_nom','p_mdp','p_email',p_origine,'p_inscription_id',p_sexe) VALUES (%s, %s, %s, %d, %s, %d)",name, inputtext, inscription_email[playerid],inscription_origine[playerid],returnIp(playerid),inscription_sexe[playerid]);



Re: mysql error [+4rep] - Vince - 28.04.2014

Quote:
Originally Posted by Conradus
Посмотреть сообщение
I think strings need to be in qoates in a mysql query, can you give this a try?
You are correct about the quotes, but you still placed them in the wrong place. It is the values that need to be enclosed, not the field names;
PHP код:
 INSERT INTO comptes (p_nom,p_mdp,p_email,p_origine,p_inscription_id,p_sexeVALUES ('%s''%s''%s', %d'%s', %d
And @OP: NEVER pass inputtext directly into a query! This is extremely dangerous. Use mysql_format or mysql_real_escape_string when inserting user input (from a text, command or dialogbox) into a query.


Re: mysql error [+4rep] - DarkZeroX - 28.04.2014

No :/

[12:48:43] Passing query INSERT INTO comptes (p_nom,p_mdp,p_email,p_origine,p_inscription_id,p_ sexe,p_code) VALUES ('DarkZeroX', 'test', 'test@laposte.net', 1, '127.0.0.1', 1, 6322)


Re: mysql error [+4rep] - Aliassassin123456 - 28.04.2014

I suggest you to use:
pawn Код:
format(string, 256, "INSERT INTO `comptes` (p_nom,p_mdp,p_email,p_origine,p_inscription_id,p_sexe) VALUES ('%s', '%s', '%s', '%d', '%s', '%d')",name, inputtext, inscription_email[playerid],inscription_origine[playerid],returnIp(playerid),inscription_sexe[playerid]);
test it ...
+ What Vince said, using mysql_escape_string is important.
Edit: No reputation received LOL Nab when your problem solved give my rep lol