|
 |
|
ช่วยด้วยครับ ขึ้นข้อผิดพลาดว่า 'เกิดข้อมผิดพลาด ไม่สามารถแก้ไขข้อมูลได้ กรุณาลองใหม่' |
|
 |
|
|
 |
 |
|
Code (PHP)
//--------------------------------------------เพิ่มการศึกษา-------------------------------------------//
if($chk_submit=="add"){
//เช็คกันการศึกษาสูงสุดซ้ำ
if(trim($study_status)<>""){
$sql="select auto_id,study_status FROM tt_ps_education where card_id = '$s_person_cardid' and study_status = 'H' ";
$re_chk_h =mysql_query($sql);
if(mysql_num_rows($re_chk_h) > 0){
$rw_chk_h=mysql_fetch_array($re_chk_h,MYSQL_ASSOC);
$sql="UPDATE `tt_ps_education` SET `study_status` = 'N' WHERE `card_id` = '$s_person_cardid' ";
$re_uddate=mysql_query($sql);
}
}elseif(trim($study_now)<>""){
$sql="select auto_id, study_status from tt_ps_education where card_id = '$s_person_cardid' and study_status = 'S' ";
$re_chk_s =mysql_query($sql);
if(mysql_num_rows($re_chk_s) > 0){
$rw_chk_s=mysql_fetch_array($re_chk_s,MYSQL_ASSOC);
$auto_id=$rw_chk_s['auto_id'];
$sql="UPDATE `tt_ps_education` SET `study_status` = 'N' WHERE `auto_id` = '$auto_id' ";
$re_uddate=mysql_query($sql);
}
}
//วันที่เริ่มศึกษา
$start_date=$start_y."-".$start_m."-".$start_d;
//วันที่จบ
$stop_date=$stop_y."-".$stop_m."-".$stop_d;
if(trim($edu_province) == ""){
$edu_province = "99";
}
$sql="INSERT INTO `tt_ps_education` ( `auto_id`,`card_id` , `edulevel_id` , `degree` , `major` , `college` , `province_id` , `study_start` , `study_stop` , `study_status`, `national` )
VALUES ('', '$s_person_cardid', '$edulevel_id', '$edu_degree', '$edu_major', '$edu_place', '$edu_province', '$start_date', '$stop_date' ";
if(trim($study_status)<>""){
$sql.=", 'H' ";//สุงสุด
}elseif(trim($study_now)<>""){
$sql.=", 'S' ";//กำลังศึกษา
}else{
$sql.=", 'N' ";//จบการศึกษาแล้ว
}
$sql .= ", '$edu_city') ";
$resule_edu=mysql_query($sql);
if(mysql_affected_rows() >0){
//กระโดดไปไฟล์ person.php
echo "<script language=\"JavaScript\">";
echo "alert('บันทึกข้อมูลการศึกษา เรียบร้อยแล้ว');";
echo "window.location='person_education.php' ";
echo "</script>";
exit;
}else{
//กระโดดไปไฟล์ person.php
echo "<script language=\"JavaScript\">";
echo "alert('เกิดข้อมผิดพลาด ไม่สามารถแก้ไขข้อมูลได้ กรุณาลองใหม่');";
echo "window.location='person_education.php' ";
echo "</script>";
exit;
}
}
//-----------------------จบการทำการเพิ่ม------------------------------//
Code
Tag : PHP, MySQL, JavaScript, Linux

|
ประวัติการแก้ไข 2012-10-30 09:58:46
|
 |
 |
 |
 |
Date :
2012-10-30 09:53:18 |
By :
tiang4157 |
View :
1023 |
Reply :
2 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
เป็นโปรแกรมที่คนอื่นเขียนขึ้นมา แล้วผมเพิ่งย้ายมาแทนที่ เลยไม่ค่อยถนัดครับ ความรู้ยังน้อยอยู่ด้วย
รบกวนท่านผู้รู้ทั้งหลาย ช่วยบอกผมทีว่า ควรแก้ไขอย่างไร
ผมลองลงข้อมูลไปแล้ว เมื่อกดบันทึกข้อมูล จะขึ้นข้อความในบรรทัดที่ 59 ทุกครั้ง
|
 |
 |
 |
 |
Date :
2012-10-30 09:55:18 |
By :
tiang4157 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
sql อาจผิดพลาด หรือไม่ก็ มีค่าซ้ำใน unique field
http://www.pjgunner.com
|
 |
 |
 |
 |
Date :
2012-10-30 10:06:34 |
By :
pjgunner.com |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 02
|