我是相當新的php。我得到行($ stmt-> bindParam(「:e1」,$ _POST ['eidosmetaf1']);)錯誤「Undefined variable:stmt在「。這似乎是一個基本的錯誤,但我無法弄清楚。所以,任何幫助表示讚賞php - 未定義的變量:stmt in
<?php
require("config.inc.php");
$query = "UPDATE customer SET ";
if(isset($_POST['eidosmetaf1'])){
$stmt->bindParam(":e1", $_POST['eidosmetaf1']);
$query .= "eidosmetaf1 = :e1";
}
$query = "UPDATE customer SET ";
if(isset($_POST['weight1'])){
$stmt->bindParam(":w1", $_POST['weight1']);
$query .= "weight1 = :w1";
}
$query = "UPDATE customer SET ";
if(isset($_POST['startNomos1'])){
$stmt->bindParam(":sn1", $_POST['startNomos1']);
$query .= "startNomos1 = :sn1";
}
$query = "UPDATE customer SET ";
if(isset($_POST['startPoli1'])){
$stmt->bindParam(":sc1", $_POST['startPoli1']);
$query .= "startPoli1 = :sc1";
}
$query = "UPDATE customer SET ";
if(isset($_POST['start_lat'])){
$stmt->bindParam(":slat1", $_POST['start_lat']);
$query .= "start_lat = :slat1";
}
$query = "UPDATE customer SET ";
if(isset($_POST['start_lng'])){
$stmt->bindParam(":slng1", $_POST['start_lng']);
$query .= "start_lng = :slng1";
}
$query = "UPDATE customer SET ";
if(isset($_POST['finalNomos1'])){
$stmt->bindParam(":fn1", $_POST['finalNomos1']);
$query .= "finalNomos1 = :fn1";
}
$query = "UPDATE customer SET ";
if(isset($_POST['finalPoli1'])){
$stmt->bindParam(":fc1", $_POST['finalPoli1']);
$query .= "finalPoli1 = :fc1";
}
$query = "UPDATE customer SET ";
if(isset($_POST['final_lat'])){
$stmt->bindParam(":flat1", $_POST['final_lat']);
$query .= "final_lat = :flat1";
}
$query = "UPDATE customer SET ";
if(isset($_POST['final_lng'])){
$stmt->bindParam(":flng1", $_POST['final_lng']);
$query .= "final_lng = :flng1";
}
$query = "UPDATE customer SET ";
if(isset($_POST['depDate1'])){
$stmt->bindParam(":dD1", $_POST['depDate1']);
$query .= "depDate1 = :dD1";
}
$query = "UPDATE customer SET ";
if(isset($_POST['depTime1'])){
$stmt->bindParam(":dT1", $_POST['depTime1']);
$query .= "depTime1 = :dT1";
}
$query = "UPDATE customer SET ";
if(isset($_POST['specialservices1'])){
$stmt->bindParam(":ex1", $_POST['specialservices1']);
$query .= "specialservices1 = :ex1";
}
$query = "UPDATE customer SET ";
if(isset($_POST['comments1'])){
$stmt->bindParam(":c1", $_POST['comments1']);
$query .= "comments1 = :c1";
}
try {
$stmt = $db->prepare($query);
$stmt->execute();
}
catch (PDOException $ex) {
$response["success"] = 0;
$response["message"] = "Database Error2. Please Try Again!";
die(json_encode($response));
}
$response["success"] = 1;
$response["message"] = "..............!";
echo json_encode($response);
?>
首先準備語句然後綁定你的價值觀 – Rizier123 2015-03-30 19:09:53
準備好你的語句,然後綁定值。 – 2015-03-30 19:11:46
抱歉,您的意思是移動「$ stmt = $ db-> prepare($ query);」在頂端; – johnnal 2015-03-30 19:13:12