2016-06-09 156 views
1

我在这里更新记录的代码问题是,当我尝试更新记录并点击提交按钮时总是显示我不确定指数的错误.. 我希望有人能帮助我这个,我努力解决这个问题..注意:未定义的索引:第28行的D: wamp www LTID Updaterlbet.php中的ID

这里的错误:

Notice: Undefined index: ID in D:\wamp\www\LTID\Updaterlbet.php on line 28
Notice: Undefined index: Province in D:\wamp\www\LTID\Updaterlbet.php on line 31
Notice: Undefined index: RLBET_Action in D:\wamp\www\LTID\Updaterlbet.php on line 39 Notice: Undefined index: Month_Approved in D:\wamp\www\LTID\Updaterlbet.php on line 41 Notice: Undefined index: Year_Approved in D:\wamp\www\LTID\Updaterlbet.php on line 42
Notice: Undefined index: Summary_of_Reason in D:\wamp\www\LTID\Updaterlbet.php on line 45 SQLSTATE[HY093]: Invalid parameter number: parameter was not defined

这里is class.user.php

public function update($ID,$LHID,$LO_Name,$Province,$Municipality,$Barangay,$Title_Number,$Lot_Number,$Survey_Number,$Area,$Resolution_Number,$RLBET_Action,$Resolution_Date,$Month_Approved,$Year_Approved,$PARCCOM_Number,$PARCCOM_Date,$Summary_of_Reason,$Reason_for_Deduction,$Date_Inserted) 
    { 
    try 
    { 

    $stmt=$this->db->prepare("UPDATE rlbet SET LHID = :LHID,LO_Name=:LO_Name,Province=:Province, Municipality = :Municipality, Barangay = :Barangay, Title_Number = :Title_Number, Lot_Number = :Lot_Number, Survey_Number = :Survey_Number, Area = :Area, Resolution_Number = :Resolution_Number, Resolution_Date = :Resolution_Date, Month_Approved = :Month_Approved, Year_Approved = :Year_Approved, PARCCOM_Number = :PARCCOM_Number, PARCCOM_Date = :PARCCOM_Date, Summary_of_Reason = :Summary_of_Reason, Reason_for_Deduction = :Reason_for_Deduction, Date_Inserted = NOW() WHERE ID = :ID"); 

    $stmt->bindparam(":LHID",$LHID); 
    $stmt->bindparam(":LO_Name",$LO_Name); 
    $stmt->bindparam(":Province",$Province); 
    $stmt->bindparam(":Municipality",$Municipality); 
    $stmt->bindparam(":Barangay",$Barangay); 
    $stmt->bindparam(":Title_Number",$Title_Number); 
    $stmt->bindparam(":Lot_Number",$Lot_Number); 
    $stmt->bindparam(":Survey_Number",$Survey_Number); 
    $stmt->bindparam(":Area",$Area); 
    $stmt->bindparam(":Resolution_Number",$Resolution_Number); 
    $stmt->bindparam(":RLBET_Action",$RLBET_Action); 
    $stmt->bindparam(":Resolution_Date",$Resolution_Date); 
    $stmt->bindparam(":Month_Approved",$Month_Approved); 
    $stmt->bindparam(":Year_Approved",$Year_Approved); 
    $stmt->bindparam(":PARCCOM_Number",$PARCCOM_Number); 
    $stmt->bindparam(":PARCCOM_Date",$PARCCOM_Date); 
    $stmt->bindparam(":Summary_of_Reason",$Summary_of_Reason); 
    $stmt->bindparam(":Reason_for_Deduction",$Reason_for_Deduction); 
    $stmt->bindparam(":ID",$ID); 
    $stmt->execute(); 

     return true; 
    } 
    catch(PDOException $e) 
    { 
     echo $e->getMessage(); 
     return false; 
    } 
    } 

Updaterlbet.php

<?php 
include_once 'db.php'; 

$LHID = isset($_GET['LHID']) ? $_GET['LHID'] : ''; 
$LO_Name = isset($_GET['LO_Name']) ? $_GET['LO_Name'] : ''; 
$Province = isset($_GET['Province']) ? $_GET['Province'] : ''; 
$Municipality = isset($_GET['Municipality']) ? $_GET['Municipality'] : ''; 
$Barangay = isset($_GET['Barangay']) ? $_GET['Barangay'] : ''; 
$Title_Number = isset($_GET['Title_Number']) ? $_GET['Title_Number'] : ''; 
$Lot_Number = isset($_GET['Lot_Number']) ? $_GET['Lot_Number'] : ''; 
$Survey_Number = isset($_GET['Survey_Number']) ? $_GET['Survey_Number'] : ''; 
$Area = isset($_GET['Area']) ? $_GET['Area'] : ''; 
$Resolution_Number = isset($_GET['Resolution_Number']) ? $_GET['Resolution_Number'] : ''; 
$RLBET_Action = isset($_GET['RLBET_Action']) ? $_GET['RLBET_Action'] : ''; 
$Resolution_Date = isset($_GET['Resolution_Date']) ? $_GET['Resolution_Date'] : ''; 
$Month_Approved = isset($_GET['Month_Approved']) ? $_GET['Month_Approved'] : ''; 
$Year_Approved = isset($_GET['Year_Approved']) ? $_GET['Year_Approved'] : ''; 
$PARCCOM_Number = isset($_GET['PARCCOM_Number']) ? $_GET['PARCCOM_Number'] : ''; 
$PARCCOM_Date = isset($_GET['PARCCOM_Date']) ? $_GET['PARCCOM_Date'] : ''; 
$Summary_of_Reason = isset($_GET['Summary_of_Reason']) ? $_GET['Summary_of_Reason'] : ''; 
$Reason_for_Deduction = isset($_GET['Reason_for_Deduction']) ? $_GET['Reason_for_Deduction'] : ''; 
$Date_Inserted = isset($_GET['Date_Inserted']) ? $_GET['Date_Inserted'] : ''; 

if ($_SERVER["REQUEST_METHOD"] == "POST") 
{ 
$ID = $_GET['ID']; 
$LHID = $_POST['LHID']; 
$LO_Name = $_POST['LO_Name']; 
$Province = $_POST['Province']; 
$Municipality = $_POST['Municipality']; 
$Barangay = $_POST['Barangay']; 
$Title_Number = $_POST['Title_Number']; 
$Lot_Number = $_POST['Lot_Number']; 
$Survey_Number = $_POST['Survey_Number']; 
$Area = $_POST['Area']; 
$Resolution_Number = $_POST['Resolution_Number']; 
$RLBET_Action = $_POST['RLBET_Action']; 
$Resolution_Date = $_POST['Resolution_Date']; 
$Month_Approved = $_POST['Month_Approved']; 
$Year_Approved = $_POST['Year_Approved']; 
$PARCCOM_Number = $_POST['PARCCOM_Number']; 
$PARCCOM_Date = $_POST['PARCCOM_Date']; 
$Summary_of_Reason = $_POST['Summary_of_Reason']; 
$Reason_for_Deduction = $_POST['Reason_for_Deduction']; 
$Date_Inserted = $_POST['Date_Inserted']; 

if($LTID->update($ID, $LHID, $LO_Name, $Province, $Municipality, $Barangay, $Title_Number, $Lot_Number, $Survey_Number, $Area, $Resolution_Number, $RLBET_Action, $Resolution_Date, $Month_Approved, $Year_Approved, $PARCCOM_Number, $PARCCOM_Date, $Summary_of_Reason, $Reason_for_Deduction, $Date_Inserted)) 
{ 

    echo "<script type='text/javascript'>alert('Successfully Updated!');</script>"; 
} 
else 
{ 
    echo "<script type='text/javascript'>alert('Updating Failed!'); </script>"; 
} 
} 

if(isset($_GET['ID'])) 
{ 
$ID = $_GET['ID']; 
extract($LTID->getID($ID)); 
} 
?> 
+1

[PHP的可能重复:“通知:未定义变量”和“通知:未定义指数“](http://stackoverflow.com/questions/4261133/php-notice-undefined-variable-and-notice-undefined-index) – ASR

+0

@ASR它不重复我的问题是不同的,我努力与此为一几天,我仍然没有解决它 – kier

+0

你有没有尝试推荐的解决方案/在这个问题上指定的答案? http://stackoverflow.com/questions/4261133/php-notice-undefined-variable-and-notice-undefined-index?answertab=active#tab-top – ASR

回答

1

我不知道你正在使用$_GET$_POSTID

请检查所有参数是否设置或不喜欢

$ID = isset($_GET['ID']) ? $_GET['ID'] : 0 ; 
$Province = isset($_POST['Province']) ? $_POST['Province'] : ''; 

这将帮助您摆脱undefined index通知。

对于SQLSTATE错误,你绑定:RLBET_Action,忘了,当你准备语句

希望增加这将有助于

相关问题