注意:未定义的索引:第28行的D:\ wamp \ www \ LTID \ Updaterlbet.php中的ID

时间:2016-06-09 03:26:47

标签: php pdo

我这里有更新记录的代码问题是,当我尝试更新记录并点击提交按钮时,它总是向我显示未定义索引的错误。 我希望有人可以帮助我,我正在努力解决这个问题。

以下是错误:

  

注意:未定义索引:D:\ wamp \ www \ LTID \ Updaterlbet.php中的ID   第28行   注意:未定义的索引:省份   第31行的D:\ wamp \ www \ LTID \ Updaterlbet.php
  注意:未定义的索引:   第39行的D:\ wamp \ www \ LTID \ Updaterlbet.php中的RLBET_Action   注意:   未定义的索引:Month_Approved在D:\ wamp \ www \ LTID \ Updaterlbet.php上   第41行   注意:未定义的索引:Year_Approved in   第42行的D:\ wamp \ www \ LTID \ Updaterlbet.php
  注意:未定义的索引:   第45行的D:\ wamp \ www \ LTID \ Updaterlbet.php中的Summary_of_Reason   SQLSTATE [HY093]:参数号无效:参数未定义

,这是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 个答案:

答案 0 :(得分:1)

我不确定您使用$_GET$_POST进行ID

尝试检查所有参数是否已设置

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

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

对于SQLSTATE错误,您绑定:RLBET_Action并忘记在准备语句时添加

希望这会有所帮助

相关问题