|
|
|
PHP Sessionไม่ยอมลบ Delete ค่า มีวิธีแก้ไขป่าวครับมีโค้ตให้ดูครับ..... |
|
|
|
|
|
|
|
Code (PHP)
ob_start();
session_start();
$reqdate = isset($_REQUEST['reqdate']) ? mysql_real_escape_string($_REQUEST['reqdate']):date("Y-m-d");
$reqby = isset($_REQUEST['reqby']) ? strval($_REQUEST['reqby']): '';
$reqapprovedept = isset($_REQUEST['reqapprovedept']) ? strval($_REQUEST['reqapprovedept']):'';
$reqapprove = isset($_REQUEST['reqapprove']) ? strval($_REQUEST['reqapprove']): '';
$supplierid = isset($_REQUEST['supplierid']) ? intval($_REQUEST['supplierid']): 0;
$orderdate = isset($_REQUEST['orderdate'])? mysql_real_escape_string($_REQUEST['orderdate']):date("Y-m-d");
$orderno = isset($_REQUEST['orderno']) ? strval($_REQUEST['orderno']):'';
$payment = isset($_REQUEST['payment']) ? strval($_REQUEST['payment']):'';
$deliverydate = isset($_REQUEST['deliverydate']) ? mysql_real_escape_string($_REQUEST['deliverydate']):date("Y-m-d");
$rerived = isset($_REQUEST['rerived']) ? strval($_REQUEST['rerived']):'';
$issue = isset($_REQUEST['issue']) ? strval($_REQUEST['issue']):'';
$approve = isset($_REQUEST['approve']) ? strval($_REQUEST['approve']):'';
$companyid = isset($_REQUEST['companyid']) ? intval($_REQUEST['companyid']):0;
$upperdescription = isset($_REQUEST['upperdescription']) ? strval($_REQUEST['upperdescription']): '';
$lowerdescription = isset($_REQUEST['lowerdescription']) ? strval($_REQUEST['lowerdescription']): '';
$status = isset($_REQUEST['status']) ? intval($_REQUEST['status']): 0;
$vat = isset($_REQUEST['vat']) ? intval($_REQUEST['vat']): 7.00;
$recieveno = isset($_REQUEST['recieveno']) ? strval($_REQUEST['recieveno']):'';
$discount = isset($_REQUEST['discount']) ? intval($_REQUEST['discount']):0;
$iniso = isset($_REQUEST['iniso'])? intval($_REQUEST['iniso']): 0;
include '../conn.php';
if(isset($_SESSION["intLine"]) && isset($_SESSION["strProID"])){
for($i=0;$i<=(int)$_SESSION["intLine"];$i++){
if(!empty($_SESSION["strProID"][$i])){
$Sql ="insert into purchaselist(orderno,productid,quantity,priceperunit,amount)";
$Sql.=" values ";
$Sql.="('$orderno','".$_SESSION["strProID"][$i]."','".$_SESSION["strQty"][$i]."'";
$Sql.=",'".$_SESSION["strPriceperUnit"][$i]."','".$_SESSION["strAmount"][$i]."')";
$Result = @mysql_query($Sql);
if($Result){
unset($_SESSION["strProID"][$i]);
unset($_SESSION["strQty"][$i]);
unset($_SESSION["strPriceperUnit"][$i]);
unset($_SESSION["strAmount"][$i]);
}else{
echo json_encode(array('msg'=>'Some errors occured. '.mysql_error()));
exit();
}
}
}
}
session_destroy();
if(empty($iniso)){
$sql = "insert into purchase(reqdate,reqby,reqapprovedept,reqapprove,supplierid,orderdate,orderno,payment,deliverydate,rerived,issue";
$sql.= ",approve,companyid,upperdescription,lowerdescription,status,vat,recieveno,discount,iniso)";
$sql.= " values ";
$sql.= "('$reqdate','$reqby','$reqapprovedept','$reqapprove','$supplierid','$orderdate','$orderno','$payment','$deliverydate','$rerived','$issue'";
$sql.= ",'$approve','$companyid','$upperdescription','$lowerdescription','$status','$vat','$recieveno','$discount','0')";
$result = @mysql_query($sql);
if ($result){
echo json_encode(array('success'=>true));
} else {
echo json_encode(array('msg'=>'Some errors occured. '.mysql_error()));
}
}else{
$sql = "insert into purchase(reqdate,reqby,reqapprovedept,reqapprove,supplierid,orderdate,orderno,payment,deliverydate,rerived,issue";
$sql.= ",approve,companyid,upperdescription,lowerdescription,status,vat,recieveno,discount,iniso)";
$sql.= " values ";
$sql.= "('$reqdate','$reqby','$reqapprovedept','$reqapprove','$supplierid','$orderdate','$orderno','$payment','$deliverydate','$rerived','$issue'";
$sql.= ",'$approve','$companyid','$upperdescription','$lowerdescription','$status','$vat','$recieveno','$discount','1')";
$result = @mysql_query($sql);
if ($result){
echo json_encode(array('success'=>true));
} else {
echo json_encode(array('msg'=>'Some errors occured. '.mysql_error()));
}
}
รบกวนช่วยดูให้หน่อยครับ
Tag : PHP, MySQL, Windows
|
|
|
|
|
|
Date :
2012-12-21 14:23:34 |
By :
GhostLocal |
View :
1011 |
Reply :
1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ลองตรวจสอบการ return ค่าของ mysql_query ดูครับ :D
|
|
|
|
|
Date :
2012-12-21 14:28:37 |
By :
itpcc |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 05
|