开发者

SQL syntax; Error

开发者 https://www.devze.com 2023-02-14 04:41 出处:网络
I am trying to add this query to database and I can\'t get it to work. Any help will be appreciated. I am trying to learn mysql I saw a website has a reservation system and I just wanted to learn how

I am trying to add this query to database and I can't get it to work. Any help will be appreciated. I am trying to learn mysql I saw a website has a reservation system and I just wanted to learn how to create one.. but I get this error.

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 ''reservation'( service_type, passengers, sedans, s' at line 1

$query = "INSERT INTO 'example'(
                service_type,
                passengers,
                sedans,
                suv,
                limo,
                pass_name,
                pass_phone,
                pass_email,
                book_name,
                book_phone,
                pickup_type,
                pickup_point,
                pickup_airline,
                pickup_flightno,
                pick_airportlocation,
                pick_address,
                reservation_datetime,
                drop_type,
                drop_airline,
                drop_flightno,
                drop_address,
                stop_1,
                stop_2,
                stop_3,
                stop_4,
                stop_5,
                stop_6,
                stop_7,
                stop_8,
                stop_9,
    开发者_运维技巧            stop_10,
                additional_info,
                payment_type,
                pickup_latitude,
                pickup_longitude,
                drop_latitude,
                drop_longitude,
                created
                ) VALUES (
                '$service_type',
                '$passengers',
                '$sedans',
                '$suv',
                '$limo',
                '$pass_name',
                '$pass_phone',
                '$pass_email',
                '$book_name',
                '$book_phone',
                '$pickup_type',
                '$pickup_point',
                '$pickup_airline',
                '$pickup_flightno',
                '$pick_airportlocation',
                '$pick_address',
                '$reservation_datetime',
                '$drop_type',
                '$drop_airline',
                '$drop_flightno',
                '$drop_address',
                '$stop_1',
                '$stop_2',
                '$stop_3',
                '$stop_4',
                '$stop_5',
                '$stop_6',
                '$stop_7',
                '$stop_8',
                '$stop_9',
                '$stop_10',
                '$additional_info',
                '$payment_type',
                '$pickup_latitude',
                '$pickup_longitude',
                '$drop_latitude',
                '$drop_longitude',
                '$created')";


Your table name needs to be enclosed in backticks `, not single quotes ':

INSERT INTO `example`


If you have variables that are strings you need to quote them in the insert statement. This is a very common mistake that people do.

0

精彩评论

暂无评论...
验证码 换一张
取 消