Saving String in MySQL
#1

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`
--
Reply
#2

Try this
pawn Код:
format(Query, sizeof(Query), "INSERT INTO `labels` (LabelX, LabelY, LabelZ, LabelInfo) VALUES(%f, %f, %f, '%s')",
    LX, LY, LZ, LabelInfo);
Reply
#3

AHHHH :< Thanks. I should pay more attention to the logs next time

Код:
'this string, see if it saves :o)'
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)