SA-MP Forums Archive
SQL sintax error - 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: SQL sintax error (/showthread.php?tid=617728)



SQL sintax error - TheDarkBlade - 25.09.2016

PHP код:
                    new Float:APosX,Float:APosY,Float:APosZ,string[128];
                    
GetPlayerPos(playerid,APosX,APosY,APosZ);
                    
mysql_format(sql,string,sizeof(string),"INSERT INTO `houses` ( `ExteriorX`, `ExteriorY`, `ExteriorZ`, `InteriorX`, `InteriorY`, `InteriorZ`) VALUES ('%f','%f','%f',140.17,1336.06,1083.65)",APosX,APosY,APosZ);
                    
mysql_tquery(sql,string,"",""); 
Код:
[19:39:27] [DEBUG] mysql_format - connection: 1, len: 128, format: "INSERT INTO `houses` ( `ExteriorX`, `ExteriorY`, `ExteriorZ`, `InteriorX`, `InteriorY`, `InteriorZ`) VALUES ('%f','%f','%f',140...."
[19:39:27] [ERROR] mysql_format - destination size is too small
[19:39:27] [DEBUG] mysql_tquery - connection: 1, query: "INSERT INTO `houses` ( `ExteriorX`, `ExteriorY`, `ExteriorZ`, `I", callback: "(null)", format: "(null)"
[19:39:27] [DEBUG] CMySQLQuery::Execute[] - starting query execution
[19:39:27] [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 ''939.337' at line 1
[19:39:27] [DEBUG] CMySQLQuery::Execute[] - error will be triggered in OnQueryError



Re: SQL sintax error - Shinja - 25.09.2016

increase string size


Re: SQL sintax error - Sawalha - 25.09.2016

every value involved in a mysql query should be enclosed with a double ' on the beginning and the ending of the value;

Код:
mysql_format(sql,string,sizeof(string),"INSERT INTO `houses` ( `ExteriorX`, `ExteriorY`, `ExteriorZ`, `InteriorX`, `InteriorY`, `InteriorZ`) VALUES ('%f','%f','%f','140.17,1336.06','1083.65')",APosX,APosY,APosZ);