MySQL INSERT issue
#1

Hi all,

I have a strange issue with my script. It's to do with logging chatlog with MySQL.

When the the script tries to execute the following MySQL statement:

Код:
INSERT INTO `chat_log`(`id`, `character_id`, `text`, `unix_timestamp`) VALUES (NULL,1,'Joe Bloggs: Test',1467728625);
INSERT INTO `chat_log`(`id`, `character_id`, `text`, `unix_timestamp`) VALUES (NULL,1,'Joe Bloggs: Test',1467728625);
INSERT INTO `chat_log`(`id`, `character_id`, `text`, `unix_timestamp`) VALUES (NULL,1,'Joe Bloggs: Test',1467728625);
INSERT INTO `chat_log`(`id`, `character_id`, `text`, `unix_timestamp`) VALUES (NULL,1,'Joe Bloggs: Test',1467728625);
INSERT INTO `chat_log`(`id`, `character_id`, `text`, `unix_timestamp`) VALUES (NULL,1,'Joe Bloggs: Test',1467728625);
It does not insert and gives the following error in the MySQL log:
Код:
[15:23:52] [DEBUG] mysql_tquery - connection: 1, query: " INSERT INTO `chat_log`(`id`, `character_id`, `text`, `unix_time", callback: "(null)", format: "(null)"
[15:23:52] [DEBUG] CMySQLQuery::Execute[] - starting query execution
[15:23:52] [ERROR] CMySQLQuery::Execute[] - (error #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 'INSERT INTO `chat_log`(`id`, `character_id`, `text`, `unix_timestamp`) VALUES (N' at line 1
[15:23:52] [DEBUG] CMySQLQuery::Execute[] - error will be triggered in OnQueryError
However, if I take those MySQl statement as they are there as I've posted, and try to insert them using phpmyadmin, they insert absolutely fine and pop up with 0 errors.

Any ideas?
Reply
#2

It looks like your query string is simply too short. However, it's worth noting that you don't need to specify the column list if you insert into every column (in order).
Reply
#3

unix_timestamp = unix_time ?
Reply
#4

If id = null and it has auto increment in DB you don't need to use it in query. Just skip this value and column in INSERT. I think NULL is the problem, cause in sa-mp you need to type it by small letters.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)