2011-03-01 209 views
0

我想將這個查詢添加到數據庫,我無法讓它工作。任何幫助將不勝感激。我想學習MySQL我看到一個網站有一個預訂系統,我只是想學習如何創建一個..但我得到這個錯誤。SQL語法;錯誤

您的SQL語法錯誤;檢查對應於你的MySQL服務器版本使用附近的'保留「(SERVICE_TYPE,乘客,轎車,S」在行正確的語法手冊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

你的表名需要被封閉在反引號`,而不是單引號「:。

INSERT INTO `example` 
+0

+1哦,是的。 .. :) – alex

0

如果你有你需要引用它們在INSERT語句中的字符串變量,這是一個非常常見的錯誤,人們做