Syntax in database - 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: Syntax in database (
/showthread.php?tid=646729)
Syntax in database -
Klayton - 22.12.2017
Hello guys, after enter my value, he not convert in text in my database, how to fix please ?
my script:
https://pastebin.com/nvNGSiNg
screenshot of dabatase result:
http://prntscr.com/hr1xu8
Re: Syntax in database -
SyS - 22.12.2017
What is villenaissance field's type? Is it string? then you don't have to use strval and convert it to integer.And use single quotes (
'%q
' for standard format) if it is string.If it is integer use %d
Re: Syntax in database -
Misiur - 22.12.2017
"%e" is not supported by standard "format", use "mysql_format". Also, strings must be enclosed in quotes, i.e "field_value = '%e'"
Re: Syntax in database -
Klayton - 22.12.2017
Quote:
mysql_format(dbhandle, query, sizeof(query), "UPDATE `server_fiches` SET couleur_yeux='%e' WHERE player_id = %d", coloryeux, PlayerInfo[playerid][p_ID]);
mysql_tquery(dbhandle, query, "SendQuery", "");
|
Quote:
case DIALOG_FICHE_COLOR_YEUX:
{
new coloryeux = strval(inputtext);
new query[700];
if(!response)
return 0;
SendClientMessageF(playerid, COLOR_LIGHTBLUE, "Bien vos yeux sont de couleur: %s", inputtext);
ShowPlayerDialog(playerid, DIALOG_FICHE_TAILLE, DIALOG_STYLE_INPUT, "Crйation de votre fiche", "Entrez la taille de votre personnage:", "Valider", "Quitter");
//format(query, sizeof(query), "UPDATE `server_fiches` SET couleur_yeux=%e WHERE player_id=%d", coloryeux, PlayerInfo[playerid][p_ID]);
//mysql_tquery(dbhandle, query, "SendQuery", "");
//mysql_format(dbhandle, query, sizeof(query), "UPDATE `server_fiches` (couleur_yeux) VALUES ('%e')", coloryeux, PlayerInfo[playerid][p_ID]);
//mysql_tquery(dbhandle, query, "SendQuery", "");
mysql_format(dbhandle, query, sizeof(query), "UPDATE `server_fiches` SET couleur_yeux='%e' WHERE player_id = %d", coloryeux, PlayerInfo[playerid][p_ID]);
mysql_tquery(dbhandle, query, "SendQuery", "");
}
|
I have try with this, and again not convert
Screenshot of database :
http://prntscr.com/hr2dow
Re: Syntax in database -
Dayrion - 22.12.2017
Your code makes no sence. :/
"couloryeux" (wich mean eyes's color) seems to be an integer first "new coloryeux = strval(inputtext);" and after that, you try to update a string with an interger.
Also:
SendClientMessageF(playerid, COLOR_LIGHTBLUE, "Bien vos yeux sont de couleur: %s", inputtext);
mean the player have entered a color like Blue, Green, Grey, or whatever and not an interger.
Either you store the eyes's color as a string or an interger, not both of them at the same time.
Re: Syntax in database -
Klayton - 22.12.2017
Yeah I have understand, thanks, fixed !