2016-11-16 20 views
-1

插入我收到了bind_param statment前回聲,但它不能在mysql數據庫phpyadmin

$stmt = $this->conn->prepare("INSERT INTO restaurants(unique_id, name, type, longitude, latitude, value_for_money, cleanliness, view, atmosphere, staff created_at) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, NOW())"); 

    echo "ezzat wasal"; 

    $stmt->bind_param("sssddiiiii", $uuid, $name, $type, (double)$longitude, (double)$latitude, (int)$value_for_money, (int)$cleanliness, (int)$view, (int)$atmosphere, (int)$staff); 
    echo "ana zeh2et"; 
+0

,你不應該強制施加所有這些值。 – tadman

+0

什麼是錯誤輸出? – Blackbam

回答

0

你缺少staffcreated_at之間的逗號而不是之後。此外,我建議在查詢中引用的所有列名(因爲有些是保留在MySQL的話:名稱,類型,視圖):如果您在使用`bind_param`,這是一件好事

$stmt = $this->conn->prepare("INSERT INTO `restaurants` 
(`unique_id`, `name`, `type`, `longitude`, `latitude`, `value_for_money`, 
`cleanliness`, `view`, `atmosphere`, `staff`, `created_at`) 
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, NOW())"); 
+0

如果滑過,[打開'mysqli'異常]的時間(http://stackoverflow.com/questions/14578243/turning-query-errors-to-exceptions-in-mysqli)。 – tadman