0

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')";

2 Answers 2

2

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

INSERT INTO `example`
Sign up to request clarification or add additional context in comments.

Comments

0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.