2016-11-16 19 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