|
|
|
มีปัญหา Code Error ในขั่นตอนการลบเรคคอร์ดครับ (มีรูป และโค๊ดประกอบครับ) |
|
|
|
|
|
|
|
ไม่รู้ว่าเกิดขึ้นจากการผิดพลาดประการใด เมื่อผมกดลบสมาชิกเกิดข้อผิดพลาดดังรูปด้านล่าง แต่ผลลัพธ์ สามารถลบออกไปจากฐานข้อมูลได้ครับ สมาชิกคนที่ถูกลบหายไป แต่ผมจะแก้ไม่ให้ เกิดข้อผิดพลาดดังรูปอย่างไรดีครับ
และในส่วนนี้คือโค๊ดหน้าดังกล่าวครับ (ขออนุญาตินำมาแสดงเฉพาะโค๊ดที่เกี่ยวข้องครับ พวกข้อมูลอื่น ๆ เช่น พวกเทีกบ๊อกซ์ให้กรอกข้อมูล หรือปุ่มรีเซ็ต แคนเซิล ไม่ได้นำมาแสดงเพื่อจะได้ไม่ทำให้โค๊ดยาวเกินไป หรือหากต้องการผมจะได้นำมาแสดงให้ภายหลังครับ (ที่ไม่นำมาแสดงเกรงว่าหากดูแล้วมันจะไม่สวยงามครับ)
Code (PHP)
<?PHP
session_start();
if(empty($_SESSION["StaffUserID"])) header("Location:../login.php");
require_once("../../inc/candidate.inc.php");
require_once("../../inc/project.inc.php");
require_once("../../inc/payment.inc.php");
$CandidateUserFunction = new CandidateUser;
$CandidatePersonalInfoFunction = new CandidatePersonalInfo;
$CandidateEducationFunction = new CandidateEducation;
$CadidateWorkInfoFunction = new CadidateWorkInfo;
$Candidate2SubProjectFunction = new Candidate2SubProject;;
$ProjectFunction = new Project;
$PaymentFunction = new Payment;
$candidateid=$_REQUEST["candidateid"];
$userid=$_REQUEST["userid"];
$Submit = $_REQUEST["Submit"];
$Msg = "ลบผู้สมัคร";
if(isset($Submit)){
$Candidate2SubProjectFunction->RemoveSubProject($userid);
$CandidateUserFunction->RemoveUser(NULL,$candidateid);
$Msg = "ข้อมูลถูกลบแล้ว<meta http-equiv=\"refresh\" content=\"2;URL=display_candidate.php\">";
//=======Update Personal info ======//
if(!$CandidatePersonalInfoFunction->RemovePersonalInfo($candidateid)){
unset($Submit);
$Msg = "ไม่สามารถลบข้อมูลส่วนตัวได้, กรูณาติดต่อผู้ดูแลระบบ";
}//End if
//======Education Info =======//
if(!$CandidateEducationFunction->RemoveEducationHistory($candidateid)){
unset($Submit);
$Msg = "ไม่สามารถลบข้อมูลการศึกษาได้, กรูณาติดต่อผู้ดูแลระบบ";
}//End if
//====== Work info =====//
if(!$CadidateWorkInfoFunction->RemoveWorkInfo($candidateid)){
unset($Submit);
$Msg = "ไม่สามารถลบข้อมูลการทำงานได้, กรูณาติดต่อผู้ดูแลระบบ";
}//end if
//====== Payment info =====//
if(!$PaymentFunction->RemovePayment(NULL,$candidateid)){
unset($Submit);
$Msg = "ไม่สามารถลบข้อมูลการทำงานได้, กรูณาติดต่อผู้ดูแลระบบ";
}//end if
}//end if
if(is_numeric($candidateid)){
$Result = $CandidateUserFunction->GetUser(NULL,$candidateid);
@$userid = $Result[0]["userid"];
@$username = $Result[0]["username"];
@$projectid = $Result[0]["projectid"];
# @$subproject = $Result[0]["subproject"];
@$applicantidno = $Result[0]["applicantno"];
$Result = $ProjectFunction->GetProject($projectid);
$ProjectName = $Result [0]["projectname"];
$Result = $CandidatePersonalInfoFunction->GetPersonalInfo($candidateid);
@$personalid = $Result[0]["personnelid"];
@$title = $Result[0]["title"];
@$firstname = $Result[0]["firstname"];
@$lastname = $Result[0]["lastname"];
@$ymd = explode("-",$Result[0]["birthdate"]);
@$birthdate = $ymd[2];
@$birthmonth = $ymd[1];
@$birthyear = $ymd[0];
@$nationality = $Result[0]["nationality"];
@$race = $Result[0]["race"];
@$religion = $Result[0]["religion"];
@$mobile_phone = $Result[0]["mobile_phone"];
@$email = $Result[0]["email"];
@$resident_address = $Result[0]["resident_address"];
@$same_address = $Result[0]["same_address"];
@$contact_address = $Result[0]["contact_address"];
$Result = $CadidateWorkInfoFunction->GetWorkInfo($candidateid);
@$unemployed = $Result[0]["unemployment"];
@$occupation = $Result[0]["occupation"];
@$organization_name = $Result[0]["organizationname"];
@$position = $Result[0]["position"];
@$organization_address = $Result[0]["address"];
@$organization_telephone = $Result[0]["telephone_number"];
$Result = $CandidateEducationFunction->GetEducationHistory($candidateid);
@$institution_name = $Result[0]["institutionname"];
@$faculty = $Result[0]["faculty"];
@$branch = $Result[0]["branch"];
@$gpa = $Result[0]["gpa"];
@$graduatedyear = $Result[0]["graduatedyear"];
@$tu_get = $Result[0]["tu_get"];
@$tu_time = $Result[0]["tu_time"];
@$exsamed_year = $Result[0]["exsamedyear"];
$Result = $Candidate2SubProjectFunction->GetSubProject($userid,NULL,$projectid);
if(count($Result)){
foreach($Result as $ElementID=>$ElementValue) $subproject[] = $ElementValue["subprojectid"];
$SubProjectFunction = new SubProject;
$Result = $SubProjectFunction->GetSubProject();
foreach($Result as $ElementID=>$ElementValue)$SubProjectList[$ElementValue["subprojectid"]]=$ElementValue["subprojectname"];
}//End if
}//end if
Tag : PHP, MySQL
|
|
|
|
|
|
Date :
2011-09-20 14:47:35 |
By :
narak0001 |
View :
787 |
Reply :
6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
การเขียนเป็น class น่ะครับ เวลาจะให้คนอื่นดู เขาไม่รู้หรอกครับ ว่า class แต่ละอัน มันเขียนยังไง
ที่มัน error ใน class ดูในโค้ดที่ให้มา ก็ได้แต่เดากันไปว่ามันคืออะไร เพราะไม่ได้เห็นคลาสที่เขียน
อ่ะ ผมจะเดาให้ คือ ค่าpaymentid มีอักขระค่าว่าง (ของ html tag) เข้ามา หรือไม่มีค่าที่ระบุึ ทำให้การลบ ไม่สามารถลบได้ครับ
|
|
|
|
|
Date :
2011-09-20 14:57:12 |
By :
deawx |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ขออภัยครับพอดีว่าทำต่อจากคนเก่า ผมต้องทำส่วนที่ขาดหายไปส่วนใดบ้าง(ไม่รู้ว่าถามถูกหรือเปล่า ไม่ได้กวนครับแต่หากดูจากโค๊ดแล้วพอจะทราบหรือไม่ว่าจะต้องนำโค๊ดจากไฟล์ไหนมาแสดงครับ)
|
|
|
|
|
Date :
2011-09-20 15:15:44 |
By :
narak0001 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ไฟล์นี้ payment.inc.php
class Payment
method RemovePayment
เอามาดูครับ
หรือว่าลอง echo $candidateid=$_REQUEST["candidateid"]; ตรงนี้ออกมาดูก็ได้ มันมีอะไร
|
|
|
|
|
Date :
2011-09-20 15:32:21 |
By :
ikikkok |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ครับ โค๊ดในหน้า peyment.inc.php ครับ
Code (PHP)
<?php
require_once("examroom.inc.php");
class Payment extends ExamSeat{
var $TbPayment = "tu_candidate_payment";
var $TbCandidateUser = "tu_candidate_user";
var $TbCandidatePersonalInfo = "tu_candidate_personalinfo";
function SetPayment($CandidateID=NULL,$AccessUserID=NULL){
if(!is_numeric($CandidateID) || !is_numeric($AccessUserID))return false;
$Field = "candidateid,description,accountno,amount,bankname,bankbranch,bankrefno,paiddate,paidtime,createdate,approveruserid,approvedate ";
$Value = "$CandidateID,'','','0','Unknow','Unknow','Unknow',NOW(),NOW(),NOW(),'$AccessUserID',NOW()";
require_once("dbconnect.inc.php");
$sql = "INSERT INTO ".$this->TbPayment." ($Field) VALUES($Value)";
mysql_query($sql) or die($sql."&nbps;:&nbps;".mysql_errno()." -> ".mysql_error());
unset($sql,$Field,$Value);
return mysql_insert_id();
}//End SetPayment
function SetPayment130110($CandidateID=NULL,$AccessUserID=NULL){
if(!is_numeric($CandidateID) || !is_numeric($AccessUserID))return false;
$Field = "candidateid,paiddate,paidtime,createdate";
$Value = "$CandidateID,NOW(),NOW(),NOW()";
require_once("dbconnect.inc.php");
$sql = "INSERT INTO ".$this->TbPayment." ($Field) VALUES($Value)";
mysql_query($sql) or die($sql."&nbps;:&nbps;".mysql_errno()." -> ".mysql_error());
unset($sql,$Field,$Value);
//====== Get candidate id =====//
$sql = "SELECT projectid FROM ".$this->TbCandidateUser." WHERE candidateid=$CandidateID";
$Result = mysql_query($sql) or die($sql."&nbps;:&nbps;".mysql_errno()." -> ".mysql_error());
$row= mysql_fetch_array($Result);
$ProjectID = $row["projectid"];
unset($sql,$Field,$Value);
// $this->SetVerify($CandidateID,'yes',$AccessUserID);
$SeatResult= $this->GetAvailable(NULL,$ProjectID);
if(!is_numeric($SeatResult["roomid"])) $SeatID= $this->GetAvailable();
$this->Set($SeatResult["roomid"],$SeatResult["seatid"],$CandidateID,$AccessUserID);
return mysql_insert_id();
}//End SetPayment
function SetVerify($CandidateID=NULL,$PaidVerify=NULL,$AccessUserID=NULL){
if(!is_numeric($CandidateID) || !is_numeric($AccessUserID))return false;
$Field = "paid_verify='$PaidVerify',modifiedbyuserid=$AccessUserID,lastmodified=NOW()";
$Condition = array();
if(is_numeric($CandidateID)) $Condition[] = " candidateid=$CandidateID";
$sql = "UPDATE ".$this->TbCandidateUser." SET $Field ";
if(count($Condition)) $sql .=" WHERE ".implode(" AND ",$Condition);
require_once("dbconnect.inc.php");
mysql_query($sql) or die($sql."&nbps;:&nbps;".mysql_errno()." -> ".mysql_error());
unset($sql,$Field,$Value);
return $CandidateID;
}//End SetVerify
function GetPayment($PaymentID=NULL,$CandidateID=NULL,$RecordStart=NULL,$RecordPerPage=NULL,$Order=NULL){
$t1= $this->TbPayment;
$t2 = $this->TbCandidatePersonalInfo;
$Table = "$t1 LEFT JOIN $t2 on $t2.candidateid=$t1.candidateid";
$Field = "$t1.paymentid,$t1.candidateid,$t1.description,$t1.amount,$t1.accountno,$t1.bankname,$t1.bankbranch,$t1.bankrefno,$t1.paiddate,$t1.paidtime,$t1.approveruserid,$t1.approvedate,$t1.createdate,$t2.title,$t2.firstname,$t2.lastname";
$Condition = array();
if(is_numeric($PaymentID)) $Condition[] = " paymentid=$PaymentID";
if(is_numeric($CandidateID)) $Condition[] = " $t1.candidateid=$CandidateID";
$sql = "SELECT $Field FROM $Table";
if(count($Condition)) $sql .=" WHERE ".implode(" AND ",$Condition);
if(!empty($Order)) $sql .= " ORDER BY $Order";
if(is_numeric($RecordStart) AND is_numeric($RecordPerPage)) $sql .= " LIMIT $RecordStart,$RecordPerPage";
require_once("dbconnect.inc.php");
$result = mysql_query($sql) or die($sql."&nbps;:&nbps;".mysql_errno()." -> ".mysql_error());
while($row= mysql_fetch_array($result)){
$Value = array();
for($index=0;$index<mysql_num_fields($result);$index++){
$Field = mysql_fetch_field($result,$index);
$Value[$Field->name] = $row[$Field->name];
}//End while
$ReturnResult[] = $Value;
}//End while
unset($sql,$Field,$Condition);
return $ReturnResult;
}//End GetPayment
function BrowsePayment($ApplicantNo=NULL,$ProjectID=NULL,$Firstname=NULL,$Lastname=NULL,$Description=NULL,$Amount=NULL,$AccountNo=NULL,$Bankname=NULL,$BankBranch=NULL,$BankRefNo=NULL,$PaidDate=NULL,$PaidTime=NULL,$ApproverUserID=NULL,$ApproveDate=NULL,$Verify=NULL,$RecordStart=NULL,$RecordPerPage=NULL,$Order=NULL){
$t1 = $this->TbCandidateUser;
$t2 = $this->TbCandidatePersonalInfo;
$t3= $this->TbPayment;
$Table = "$t2 , $t1 LEFT JOIN $t3 ON $t3.candidateid=$t1.candidateid ";
$Field = "$t1.candidateid,$t1.applicantno,$t1.paid_verify,$t1.projectid,$t3.paymentid,$t3.description,$t3.amount,$t3.accountno,$t3.bankname,$t3.bankbranch,$t3.bankrefno,$t3.paiddate,$t3.paidtime,$t3.approveruserid,$t3.approvedate,$t3.createdate,$t2.title,$t2.firstname,$t2.lastname";
$Condition = array();
$Condition[] = " $t1.candidateid=$t2.candidateid ";
if(is_numeric($ApplicantNo)) $Condition[] = "$t1.applicantno='$ApplicantNo'";
if(is_numeric($ProjectID)) $Condition[] = "$t1.projectid='$ProjectID'";
if(is_numeric($PaymentID)) $Condition[] = " $t3.paymentid=$PaymentID";
if(!empty($Firstname)) $Condition[] = " $t2.firstname LIKE '$Firstname%'";
if(!empty($Lastname)) $Condition[] = " $t2.lastname LIKE '$Lastname%'";
if(!empty($Amount)) $Condition[] = " $t3.amount = '$Amount'";
if(!empty($AccountNo)) $Condition[] = " $t3.accountno = '$AccountNo'";
if(!empty($Bankname)) $Condition[] = " $t3.bankname LIKE '$Bankname%'";
if(!empty($BankBranch)) $Condition[] = " $t3.bankbranch LIKE '$BankBranch%'";
if(!empty($BankRefNo)) $Condition[] = " $t3.bankrefno LIKE '$BankRefNo%'";
if(!empty($PaidDate)) $Condition[] = " $t3.paiddate='$PaidDate'";
if(!empty($PaidTime)) $Condition[] = " $t3.paidtime='$PaidTime'";
if(is_numeric($ApproverUserID)) $Condition[] = " $t3.approveruserid=$ApproverUserID";
if(!empty($ApproveDate)) $Condition[] = " DATE_FORMAT($t3.approvedate,'%Y-%m-%d')='$ApproveDate'";
if(!empty($Verify)){
$Condition[] = "$t1.paid_verify='$Verify' ";
if($Verify=='yes') $Condition[] = "$t3.paymentid!='' ";
#elseif($Verify=='no') $Condition[] = "$t3.paymentid='' ";
}//end if
$sql = "SELECT $Field FROM $Table";
if(count($Condition)) $sql .=" WHERE ".implode(" AND ",$Condition);
$sql .= " GROUP BY $t3.candidateid";
if(!empty($Order)) $sql .= " ORDER BY $Order";
if(is_numeric($RecordStart) AND is_numeric($RecordPerPage)) $sql .= " LIMIT $RecordStart,$RecordPerPage";
require_once("dbconnect.inc.php");
$result = mysql_query($sql) or die($sql."&nbps;:&nbps;".mysql_errno()." -> ".mysql_error());
while($row= mysql_fetch_array($result)){
$Value = array();
for($index=0;$index<mysql_num_fields($result);$index++){
$Field = mysql_fetch_field($result,$index);
$Value[$Field->name] = $row[$Field->name];
}//End while
$ReturnResult[] = $Value;
}//End while
unset($sql,$Field,$Condition);
return $ReturnResult;
}//End Payment
function Summary(){
$Condition = array();
$t1 = $this->TbCandidateUser;
$t2 = $this->TbCandidatePersonalInfo;
$Table = " $t1,$t2";
$Condition[] = " $t1.candidateid=$t2.candidateid ";
$Field = " SUM(IF($t1.paid_verify='yes',1,0)) as paid, SUM(IF($t1.paid_verify='no',1,0)) as not_paid, COUNT($t1.candidateid) as total";
$sql = "SELECT $Field FROM $Table";
if(count($Condition)) $sql .=" WHERE ".implode(" AND ",$Condition);
$sql .= " GROUP BY $t1.candidateid";
require_once("dbconnect.inc.php");
$result = mysql_query($sql) or die($sql."&nbps;:&nbps;".mysql_errno()." -> ".mysql_error());
while($row= mysql_fetch_array($result)){
$Value = array();
for($index=0;$index<mysql_num_fields($result);$index++){
$Field = mysql_fetch_field($result,$index);
$Value[$Field->name] = $row[$Field->name];
}//End while
$ReturnResult[] = $Value;
}//End while
unset($sql,$Field,$Condition);
return $ReturnResult;
}//End Summary
function BrowsePayment2($ApplicantNo=NULL,$ProjectID=NULL,$Firstname=NULL,$Lastname=NULL,$Description=NULL,$Amount=NULL,$AccountNo=NULL,$Bankname=NULL,$BankBranch=NULL,$BankRefNo=NULL,$PaidDate=NULL,$PaidTime=NULL,$ApproverUserID=NULL,$ApproveDate=NULL,$RecordStart=NULL,$RecordPerPage=NULL,$Order=NULL){
$t1= $this->TbPayment;
$t2 = $this->TbCandidatePersonalInfo;
$t3 = $this->TbCandidateUser;
$Table = "$t1 LEFT JOIN $t2 on $t2.candidateid=$t1.candidateid LEFT JOIN $t3 ON $t3.candidateid=$t1.candidateid";
$Field = "$t3.applicantno,$t3.paid_verify,$t3.projectid,$t1.paymentid,$t1.candidateid,$t1.description,$t1.amount,$t1.accountno,$t1.bankname,$t1.bankbranch,$t1.bankrefno,$t1.paiddate,$t1.paidtime,$t1.approveruserid,$t1.approvedate,$t1.createdate,$t2.title,$t2.firstname,$t2.lastname,$t3.candidateid";
$Condition = array();
if(is_numeric($ApplicantNo)) $Condition[] = " $t3.applicantno='$ApplicantNo'";
if(is_numeric($ProjectID)) $Condition[] = " $t3.projectid='$ProjectID'";
if(is_numeric($PaymentID)) $Condition[] = " paymentid=$PaymentID";
if(!empty($Firstname)) $Condition[] = " firstname LIKE '$Firstname%'";
if(!empty($Lastname)) $Condition[] = " lastname LIKE '$Lastname%'";
if(!empty($Description)) $Condition[] = " description LIKE '$Description%'";
if(!empty($Amount)) $Condition[] = " amount = '$Amount'";
if(!empty($AccountNo)) $Condition[] = " accountno = '$AccountNo'";
if(!empty($Bankname)) $Condition[] = " bankname LIKE '$Bankname%'";
if(!empty($BankBranch)) $Condition[] = " bankbranch LIKE '$BankBranch%'";
if(!empty($BankRefNo)) $Condition[] = " bankrefno LIKE '$BankRefNo%'";
if(!empty($PaidDate)) $Condition[] = " paiddate='$PaidDate'";
if(!empty($PaidTime)) $Condition[] = " paidtime='$PaidTime'";
if(is_numeric($ApproverUserID)) $Condition[] = " approveruserid=$ApproverUserID";
if(!empty($ApproveDate)) $Condition[] = " DATE_FORMAT(approvedate,'%Y-%m-%d')='$ApproveDate'";
$sql = "SELECT $Field FROM $Table";
if(count($Condition)) $sql .=" WHERE ".implode(" AND ",$Condition);
if(!empty($Order)) $sql .= " ORDER BY $Order";
if(is_numeric($RecordStart) AND is_numeric($RecordPerPage)) $sql .= " LIMIT $RecordStart,$RecordPerPage";
require_once("dbconnect.inc.php");
$result = mysql_query($sql) or die($sql."&nbps;:&nbps;".mysql_errno()." -> ".mysql_error());
while($row= mysql_fetch_array($result)){
$Value = array();
for($index=0;$index<mysql_num_fields($result);$index++){
$Field = mysql_fetch_field($result,$index);
$Value[$Field->name] = $row[$Field->name];
}//End while
$ReturnResult[] = $Value;
}//End while
unset($sql,$Field,$Condition);
return $ReturnResult;
}//End BrowsePayment2
function ApprovePayment($PaymentID=NULL,$AccessUserID=NULL){
if(!is_numeric($PaymentID) || !is_numeric($AccessUserID)) return false;
$Field = "approveruserid,approvedate";
$Value = "$AccessUserID,NOW()";
$sql = "UPDATE ".$this->TbPayment." SET $Field WHERE paymentid=$PaymentID";
require_once("dbconnect.inc.php");
mysql_query($sql) or die($sql."&nbps;:&nbps;".mysql_errno()." -> ".mysql_error());
return true;
}//End UpdatePayment
function RemovePayment($PaymentID=NULL,$AccessUserID=NULL){
if(!is_numeric($PaymentID) && !is_numeric($AccessUserID)) return false;
$Condition[] = "paymentid=$PaymentID";
$sql = "DELETE FROM ".$this->TbPayment;
if(count($Condition)) $sql .=" WHERE ".implode(" AND ",$Condition);
require_once("dbconnect.inc.php");
mysql_query($sql) or die($sql."&nbps;:&nbps;".mysql_errno()." -> ".mysql_error());
unset($Condition,$sql,$Result);
return true;
}//End RemovePayment
function CheckDruplicate($PaymentID=NULL,$CandidateID=NULL){
$Field = "paymentid,candidateid";
include("dbconnect.inc.php");
$Condition = array();
if(is_numeric($PaymentID)) $Condition[] = " paymentid!=$PaymentID";
if(is_numeric($CandidateID)) $Condition[] =" candidateid='$CandidateID'";
$sql = "SELECT $Field FROM ".$this->TbPayment;
if(count($Condition)) $sql .=" WHERE ".implode(" AND ",$Condition);
$result = mysql_query($sql) or die($sql."&nbps;:&nbps;".mysql_errno()." -> ".mysql_error());
$ReturnResult = mysql_num_rows($result);
unset($sql,$Field,$Condition);
return $ReturnResult;
}//end CheckDruplicate
}//end Payment
?>
|
|
|
|
|
Date :
2011-09-21 09:04:25 |
By :
narak0001 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
สรุปให้เลยว่าเพราะ $candidateid=$_REQUEST["candidateid"]; ไม่มีค่าครับ
|
|
|
|
|
Date :
2011-09-21 11:26:31 |
By :
ikikkok |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ผมต้องทำอย่างไรบ้างครับ เพื่อจะให้ข้อผิดพลาดนี้หายไป แล้วค่าที่หายไปนี่ผมต้องทำอย่างไรบ้างครับ
|
|
|
|
|
Date :
2011-09-21 14:00:00 |
By :
narak0001 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 04
|