|
|
|
ขอคำแนะนำแก้ไขปัญหา PHP ไม่สามารถบันทึกข้อมูลเข้าฐานข้อมูล Ms Access 365 (.accdb) |
|
|
|
|
|
|
|
Code (PHP)
# Upload 1#
$upload_path[1] = "upload1/" . $_FILES['QuotationFile']['name'];
move_uploaded_file ($_FILES['QuotationFile']['tmp_name'] ,$upload_path[1]);
# Upload 2#
$upload_path[2] = "upload2/" . $_FILES['PlanFile']['name'];
move_uploaded_file ($_FILES['PlanFile']['tmp_name'] ,$upload_path[2]);
# Upload 3#
$upload_path[3] = "upload3/" . $_FILES['PorRorFile']['name'];
move_uploaded_file ($_FILES['PorRorFile']['tmp_name'] ,$upload_path[3]);
# Upload 4#
$upload_path[4] = "upload4/" . $_FILES['Pictures']['name'];
move_uploaded_file ($_FILES['Pictures']['tmp_name'] ,$upload_path[4]);
# Upload 5#
$upload_path[5] = "upload5/" . $_FILES['LandRight']['name'];
move_uploaded_file ($_FILES['LandRight']['tmp_name'] ,$upload_path[5]);
# Upload 6#
$upload_path[6] = "upload6/" . $_FILES['RequestOfficeLetterFile']['name'];
move_uploaded_file ($_FILES['RequestOfficeLetterFile']['tmp_name'] ,$upload_path[6]);
## Connect Database ##
$conn = new COM("ADODB.Connection") ;
$driver = "DRIVER={Microsoft Access Driver (*.accdb)} ; DBQ=". realpath('investment.accdb') .";" ;
$conn->Open($driver);
## Insert Data ##
$query ="
INSERT INTO Main (KeyDate,BudgetYear,NameOperateOffice,NameRegionalOffice,NameRequestOffice,NewRequest,Replacement,InvestmentType,Description,Quantity,UnitName,UnitPrice,StandardPrice,TotalPrice,LocationName,LocationAddress,LocationVillage,LocationProvince,LocationAmphur,LocationTambon,LocationPostCode,LocationLatEast,LocationLongNorth,LocationZone,ReplacementCode,ReplacementAge,ReplacementStatus,Rationale,Quotation,QuotationFile,HavePlan,PlanFile,HavePorRor,PorRorDate,PorRorFile,Pictures,LandRight,RequestPriority,RequestOfficeLetterDetail,RequestOfficeLetterFile,RequestOfficeCoordinator,Remark)
VALUES(
NOW(),
'". $_POST['BudgetYear'] ."',
'". $_POST['NameOperateOffice'] ."',
'". $_POST['NameRegionalOffice'] ."',
'". $_POST['NameRequestOffice'] ."',
'". $_POST['NewRequest'] ."',
'". $_POST['Replacement'] ."',
'". $_POST['InvestmentType'] ."',
'". $_POST['Description'] ."',
'". $_POST['Quantity'] ."',
'". $_POST['UnitName'] ."',
'". $_POST['UnitPrice'] ."',
'". $_POST['StandardPrice'] ."',
'". $_POST['TotalPrice'] ."',
'". $_POST['LocationName'] ."',
'". $_POST['LocationAddress'] ."',
'". $_POST['LocationVillage'] ."',
'". $_POST['LocationProvince'] ."',
'". $_POST['LocationAmphur'] ."',
'". $_POST['LocationTambon'] ."',
'". $_POST['LocationPostCode'] ."',
'". $_POST['LocationLatEast'] ."',
'". $_POST['LocationLongNorth'] ."',
'". $_POST['LocationZone'] ."',
'". $_POST['ReplacementCode'] ."',
'". $_POST['ReplacementAge'] ."',
'". $_POST['ReplacementStatus'] ."',
'". $_POST['Rationale'] ."',
'". $_POST['Quotation'] ."',
'". $upload_path[1] ."',
'". $_POST['HavePlan'] ."',
'". $upload_path[2] ."',
". $_POST['HavePorRor'] ."',
'". $_POST['PorRorDate'] ."',
'". $upload_path[3] ."',
'". $upload_path[4] ."',
". $upload_path[5] ."',
'". $_POST['RequestPriority'] ."',
'". $_POST['RequestOfficeLetterDetail'] ."',
'". $upload_path[6] ."',
'". $_POST['RequestOfficeCoordinator'] ."',
'". $_POST['Remark'] ."'
);
";
$rs = $conn->execute($query);
$conn->Close() ;
## Redirect to Form ##
$host = $_SERVER['HTTP_HOST'];
$uri = rtrim(dirname($_SERVER['PHP_SELF']), '/\\');
$extra = 'viewaddinvestment2.asp';
header("Location: http://$host$uri/$extra");
exit;
Tag : PHP, Ms Access, HTML
|
ประวัติการแก้ไข 2020-07-14 21:27:35
|
|
|
|
|
Date :
2020-07-14 21:25:16 |
By :
อุษา |
View :
571 |
Reply :
3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
มี Error อะไรแจ้งเตือนมั้ยครับ
|
|
|
|
|
Date :
2020-07-15 11:51:02 |
By :
Manussawin |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
หาวิธีเปิดแสดง error/warning/notice ซะนะครับ
เพราะนั่นไม่ใช่ error ที่เหมาะสำหรับ developer จะแก้ไขหาจุดผิดพลาดอะไรก็ไม่ได้
|
|
|
|
|
Date :
2020-07-15 15:04:38 |
By :
mr.v |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 05
|