MySQL Syntax error? :S
#1

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

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

Quote:

'The State'

Reply
#3

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!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)