SA-MP Forums Archive
MySQL INSERT issue - 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: MySQL INSERT issue (/showthread.php?tid=611362)



MySQL INSERT issue - Jonesy96 - 05.07.2016

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?


Re: MySQL INSERT issue - Vince - 05.07.2016

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).


Re: MySQL INSERT issue - Napst34 - 05.07.2016

unix_timestamp = unix_time ?


Re: MySQL INSERT issue - Rdx - 06.07.2016

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.