2016-11-16 3 views
-1

を挿入することができません私はbind_paramのなステートメントの前にエコーを受け取るが、それ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

関連する問題