|
 |
|
การเพิ่มข้อมูลการแจ้งซ่อม โดยมีข้อผิดพลาดเกี่ยวกับวันที่ ฟ้องว่ามีค่าซ้ำกัน และไม่เช็คค่าว่าง |
|
 |
|
|
 |
 |
|
ตอนนี้ผมกำลังทำโปรเจ็คจบครับผม มีปัญหา 2 ปัญหา
ปัญหาแรก เกี่ยวกับการเพิ่มข้อมูลการแจ้งซ่อมครับ ถ้าครั้งแรกไม่เคยแจ้งซ่อม ระบบสามารถเพิ่มได้ครับ แต่ถ้าผมส่งการแจ้งซ่อมอีกครั้ง จะฟ้องว่า เหมือนวันที่ซ้ำกันครับผม โดยที่ ฟิวด์วันที่นี้ไม่ใช้ PK ครับ โดยเพิ่มวันที่ใช้ฟังก์ชั่น NOW() ในการเก็บครับ
หน้าฟอร์มก่อนส่ง

หลังจากส่งการแจ้งครั้งที่ 2

ฐานข้อมูลการแจ้งซ่อม

Code (PHP)
include "../../config/connect_db.php";
if($_POST['textfieldDetailetc'] == ""){
$Detail_Etc = 0;
$TextDetail_Etc = '-' ;
}else{
$Detail_Etc = 1;
$TextDetail_Etc = $_POST['textfieldDetailetc'] ;
}
$strSQL = "INSERT INTO repair ( User_ID, Repair_Date, Repair_Etc, Detail_Etc, Repair_Status) ";
$strSQL .= "VALUES ( '$_SESSION[ses_user]' , NOW(),'$Detail_Etc', '$TextDetail_Etc', '1' ); ";
echo "<p class='bighand'>ระบบทำการบันทึกไว้เรียบร้อยแล้ว<br>กรุณารอสักครู่</p><br>";
echo "<img src='../../images/line.gif' width='576' height='19'>";
echo "<meta http-equiv='refresh' content='20;URL= /dormitory/user/repair/equipment.php' />";
mysql_query( $strSQL, $conn )
or die ( "ไม่สามารถส่งข้อมูลการแจ้งซ่อมได้." . mysql_error()) ;
ปัญหาที่ 2 เกี่ยวกับเช็คค่าว่างครับ Code (PHP)

code
if($_POST['textfieldDetailetc'] == ""){
$Detail_Etc = 0;
$TextDetail_Etc = '-' ;
}else{
$Detail_Etc = 1;
$TextDetail_Etc = $_POST['textfieldDetailetc'] ;
}
รายละเอียด : ถ้ารายละเอียดของผมไม่ได้กรอก $_POST['textfieldDetailetc'] ค่า $Detail_Etc จะเป็น 0 และ $TextDetail_Etc = '-'; แต่ถ้ากรอกรายละเอียดลงไป $_POST['textfieldDetailetc'] เข้าเงื่อนไขสุดท้าย ค่า $Detail_Etc จะเป็น 1 และ $TextDetail_Etc = 'อักษรที่พิมพ์ลงไป';
ผลลัพธ์คือ เมื่อผมกรอกค่ารายละเอียดหรือไม่กรอก ก็ไม่เช็คเงื่อนไขเลยครับผมไม่ทราบว่ามันเกิดอะไรขึ้นครับเกี่ยวกับ if นี้ข้ามตลอดทั้งที่ถูกต้องแล้ว ของเพื่อนผมก็เหมือนกัน
ขอบคุณล้วงหน้าที่สละเวลามาตอบครับผม ^^
Tag : PHP, MySQL, JavaScript, Windows

|
|
 |
 |
 |
 |
Date :
2012-09-01 03:34:41 |
By :
veeitdata5 |
View :
1604 |
Reply :
3 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
จาก Error ลองดูพวก Key ต่าง ๆ ครับ เพราะมันแจ้งว่าซ้ำครับเช่น Primary Key , Unique Key
|
 |
 |
 |
 |
Date :
2012-09-01 07:40:53 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 01
|