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



mysql error - n00el - 24.08.2014

Hello, i have an mysql error. Whats wrong with this?
Код:
format(query, sizeof(query), "INSERT INTO `phone_contacts` (where, name, phnumber) VALUES (%i, '%s', %i)", PlayerInfo[playerid][pID], inputtext, phnumber);
mysql_query(sqldb, query);
mysql_free_result();
Код:
[00:24:23] [DEBUG] mysql_query - connection: 1, query: "INSERT INTO `phone_contacts` (where, name, phnumber) VALUES (1, ", use_cache: true
[00:24:23] [DEBUG] CMySQLQuery::Execute - starting query execution
[00:24:23] [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 'where, name, phnumber) VALUES (1, 'asd', 1234567)' at line 1



Re: mysql error - n00el - 25.08.2014

anyone?


Re: mysql error - Smally - 25.08.2014

I believe it's because you are using a column named 'where' which is a MySQL function.


Re: mysql error - HazardouS - 25.08.2014

pawn Код:
format(query, sizeof(query), "INSERT INTO `phone_contacts` (`where`, `name`, `phnumber`) VALUES (%i, '%s', %i)", PlayerInfo[playerid][pID], inputtext, phnumber);
Replace your "format" line with this one.


Re: mysql error - F1aw1ess - 25.08.2014

I would suggest you to use this:

pawn Код:
format(query, sizeof(query), "INSERT INTO `phone_contacts` (`name`, `phnumber`) VALUES ('%s', %i)", inputtext, phnumber);
Tell me if it works.

Edit: I deleted the wrong "where" and the value you were trying to insert which had no match (PlayerInfo[playerid][pID])