|
 |
|
ไม่รู้ว่าผิดตรงไหน ถึงไม่ INSERT ข้อมูลให้ ขึ้นว่า Cannot Add Database |
|
 |
|
|
 |
 |
|
ไม่รู้ว่าผิดตรงไหน ถึงไม่ INSERT ข้อมูลให้ ขึ้นว่า Cannot Add Database
Code (PHP)
<?
@session_start();
ob_start();
$useradmin = $_SESSION["useradmin"];
if(empty($useradmin))
{
echo "<script>alert('หน้านี้จำกัดเฉพาะ Admin เท่านั้น');history.back();</script>";
exit();
}
require_once "../include/tdate.php";
require_once "../include/connect.php";
require_once "../include/connectdb.php";
$sql="select * from useradmin where useradmin='$useradmin'";
$db_query=mysql_db_query($db,$sql);
$result=mysql_fetch_array($db_query);
$id=$result[id];
$adminname=$result[name];
$user_admin=$result[useradmin];
$pass_admin=$result[passadmin];
$select_checkcourse="select * from course where course_code = '$_POST[course_code]'";
$query_select3=mysql_query($select_checkcourse);
$num_prdtype=mysql_num_rows($query_select3);
if($num_prdtype > 0){
echo "<script>alert('รหัสรายวิชานี้ถูกใช้ไปแล้ว!');history.back();</script>";
}else{
mysql_query("INSERT INTO course (course_code,course_name, credit,term,course_year,course_room,course_day,time_star,course_stop )
values('','$_POST[course_code]','$_POST[course_name]' ,'$_POST[credit]','$_POST[term]','$_POST[course_year]', '$_POST[course_room]','$_POST[course_day]','$_POST[time_star]', '$_POST[course_stop]')")or die ("Cannot Add Database");
}
?>
Tag : PHP, MySQL, HTML/CSS, CakePHP

|
|
 |
 |
 |
 |
Date :
2013-09-10 16:15:29 |
By :
amgof |
View :
586 |
Reply :
4 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
' ' เกินมาครับลบออกก็ใช้งานได้แล้ว
Code (PHP)
<?
@session_start();
ob_start();
$useradmin = $_SESSION["useradmin"];
if(empty($useradmin))
{
echo "<script>alert('หน้านี้จำกัดเฉพาะ Admin เท่านั้น');history.back();</script>";
exit();
}
require_once "../include/tdate.php";
require_once "../include/connect.php";
require_once "../include/connectdb.php";
$sql="select * from useradmin where useradmin='$useradmin'";
$db_query=mysql_db_query($db,$sql);
$result=mysql_fetch_array($db_query);
$id=$result[id];
$adminname=$result[name];
$user_admin=$result[useradmin];
$pass_admin=$result[passadmin];
$select_checkcourse="select * from course where course_code = '$_POST[course_code]'";
$query_select3=mysql_query($select_checkcourse);
$num_prdtype=mysql_num_rows($query_select3);
if($num_prdtype > 0){
echo "<script>alert('รหัสรายวิชานี้ถูกใช้ไปแล้ว!');history.back();</script>";
}else{
mysql_query("INSERT INTO course (course_code,course_name,credit,term,course_year,course_room,course_day,time_star,course_stop )
values('$_POST[course_code]','$_POST[course_name]','$_POST[credit]','$_POST[term]','$_POST[course_year]','$_POST[course_room]','$_POST[course_day]','$_POST[time_star]','$_POST[course_stop]')") or die ("Cannot Add Database");
}
?>
|
ประวัติการแก้ไข 2013-09-10 16:21:09
 |
 |
 |
 |
Date :
2013-09-10 16:20:29 |
By :
Dragons_first |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ลอง echo บรรทัดนี้ แล้วลองเอาค่าไปใส่ใน mysql ดูว่าได้รึป่าว ถ้าไม่ได้ก็แสดงว่า คำสั่งไม่ถูก
"INSERT INTO course (course_code,course_name,credit,term,course_year,course_room,course_day,time_star,course_stop ) values('','$_POST[course_code]','$_POST[course_name]','$_POST[credit]','$_POST[term]','$_POST[course_year]','$_POST[course_room]','$_POST[course_day]','$_POST[time_star]','$_POST[course_stop]')"
|
 |
 |
 |
 |
Date :
2013-09-10 16:22:48 |
By :
tt |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
mysql_query("INSERT INTO course
(course_code---------------------------------------1
,course_name,--------------------------------------2
credit,------------------------------------------------3
term,----------------------------------------------4
course_year,--------------------------------------5
course_room,------------------------------------6
course_day,---------------------------------------7
time_star,-------------------------------------------8
course_stop )---------------------------------------9
values('',-----------------------------------------1 น่าจะผิดตรงนี้นะ
'$_POST[course_code]' 2
,'$_POST[course_name]' 3
,'$_POST[credit]','$_POST[term]' 4
,'$_POST[course_year]' 5
,'$_POST[course_room]' 6
,'$_POST[course_day]' 7
,'$_POST[time_star]' 8
,'$_POST[course_stop]') 9
")
|
 |
 |
 |
 |
Date :
2013-09-10 16:24:11 |
By :
mungkorn001 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอบคุณครับ ได้แหละครับ
|
 |
 |
 |
 |
Date :
2013-09-10 16:49:48 |
By :
amgof |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 04
|