Saving String in MySQL - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Saving String in MySQL (
/showthread.php?tid=179885)
Saving String in MySQL - [L3th4l] - 29.09.2010
So yeah, I'm trying to set the 3dlabels save and load from mysql ( don't ask why )
Here is the save function:
pawn Код:
stock AddLabelToFile(LabelInfo[], Float:LX, Float:LY, Float:LZ)
{
new Query[400];
format(Query, sizeof(Query), "INSERT INTO `labels` (LabelX, LabelY, LabelZ, LabelInfo) VALUES(%f, %f, %f, %s)",
LX, LY, LZ, LabelInfo);
mysql_query(Query);
mysql_free_result();
return 1;
}
Here is the error:
Код:
[19:17:06] CMySQLHandler::Query(INSERT INTO `labels` (LabelX, LabelY, LabelZ, LabelInfo) VALUES(-1265.670532, -2117.095947, 25.773883, testing this string, see if it saves :o)) - An error has occured. (Error ID: 1064, You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'this string, see if it saves :o)' at line 1)
Not sure why I'm getting that error :<
EDIT: If needed:
Код:
-- --------------------------------------------------------
--
-- Table structure for table `labels`
--
CREATE TABLE IF NOT EXISTS `labels` (
`LabelX` float NOT NULL,
`LabelY` float NOT NULL,
`LabelZ` float NOT NULL,
`LabelInfo` varchar(128) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
--
-- Dumping data for table `labels`
--
Re: Saving String in MySQL -
Grim_ - 29.09.2010
Try this
pawn Код:
format(Query, sizeof(Query), "INSERT INTO `labels` (LabelX, LabelY, LabelZ, LabelInfo) VALUES(%f, %f, %f, '%s')",
LX, LY, LZ, LabelInfo);
Re: Saving String in MySQL - [L3th4l] - 29.09.2010
AHHHH :< Thanks. I should pay more attention to the logs next time
Код:
'this string, see if it saves :o)'