SA-MP Forums Archive
MySQL Syntax error? :S - 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: MySQL Syntax error? :S (/showthread.php?tid=168365)



MySQL Syntax error? :S - Toni - 16.08.2010

Hi, I am trying to create a house system function, but I am having a trouble when I add a house under OnGmInIt.
pawn Код:
public AddHouse(HID, Float:EntX, Float:EntY, Float:EntZ, Float:IntX, Float:IntY, Float:IntZ, IntID, VW, HPrice)
{
    new
        str[1012]
    ;
    if(HID >= MAX_HOUSES) return 0;
    format(str, sizeof(str), "SELECT * FROM `houseinfo` WHERE `HouseID` = %d", HID);
    mysql_query(str);
    mysql_store_result();
    if(mysql_num_rows() > 0) return 0;
    mysql_free_result();

    format(str, sizeof(str), "INSERT INTO `houseinfo` (HouseID, Owner, EnterX, EnterY, EnterZ, InteriorX, InteriorY, InteriorZ, InteriorID, VWorld, Price) VALUES (%d, The State, %.2f, %.2f, %.2f, %.2f, %.2f, %.2f, %d, %d, %d)", HID, EntX, EntY, EntZ, IntX, IntY, IntZ, IntID, VW, HPrice);
    mysql_query(str);
    return 1;
}
This is my error...
Код:
[Sun Aug 15 13:04:24 2010] Function: mysql_query executed: "INSERT INTO `houseinfo` (HouseID, Owner, EnterX, EnterY, EnterZ, InteriorX, InteriorY, InteriorZ, InteriorID, VWorld, Price) VALUES (1, The State, 1231.30, 2323.00, 2322.19, 2322.00, 564.00, 321.20, 1, 1, 50000)" with result: "1".
[Sun Aug 15 13:04:24 2010] Error (0): Failed to exeute query. 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 'State, 1231.30, 2323.00, 2322.19, 2322.00, 564.00, 321.20, 1, 1, 50000)' at line 1.
Please help Heh.


Re: MySQL Syntax error? :S - Calgon - 16.08.2010

Use single quotes for strings... You DEFINITELY do not need a 1012 cell string.

Quote:

'The State'




Re: MySQL Syntax error? :S - Toni - 16.08.2010

Quote:
Originally Posted by Calgon
Посмотреть сообщение
Use single quotes for strings... You DEFINITELY do not need a 1012 cell string.
I know, I just put random numbers and go down until I made it fit and thanks!