|
 |
|
ช่วยดูโค๊ด ให้หน่อยครับ แอดไม่ลง ฐานข้อมูลสักทีครับ ไม่ขึ้น error เลย |
|
 |
|
|
 |
 |
|
ฟอร์มกรอกครับCode (PHP)
<form id="form1" name="form1" method="post" action="admin_page_save_add_teacher.php">
<table width="800" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>ชื่ออาจารย์นิเทศ</td>
<td><label>
<input type="text" name="name_teacher" id="name_teacher" />
</label></td>
<td> </td>
</tr>
<tr>
<td>ห้องพักอาจารย์</td>
<td><label>
<input type="text" name="room_teacher" id="room_teacher" />
</label></td>
<td> </td>
</tr>
<tr>
<td>เบอร์โทรศัพท์ภายใน</td>
<td><label>
<input type="text" name="tele_teacher" id="tele_teacher" />
</label></td>
<td> </td>
</tr>
<tr>
<td>ต่อ</td>
<td><label>
<input type="text" name="add_tele" id="add_tele" />
</label></td>
<td> </td>
</tr>
<tr>
<td>อีเมล</td>
<td><label>
<input type="text" name="email_teacher" id="email_teacher" />
</label></td>
<td> </td>
</tr>
<tr>
<td><label>
<input type="submit" name="button" id="button" value="Submit" />
</label></td>
<td> </td>
<td> </td>
</tr>
</table>
</form>
ฟอร์มเซฟ ลงฐานข้อมูลครับCode (PHP)
<? include "include/config.php";?>
<?
if(trim($_POST["name_teacher"]) == "")
{
echo "<script> alert('กรุณากรอกชื่ออาจารย์ !!')</script>";
print "<meta http-equiv=refresh content=0;URL=register.php>";
exit();
}
if(trim($_POST["room_teacher"]) == "")
{
echo "<script> alert('กรุณากรอกห้องพัก!')</script>";
print "<meta http-equiv=refresh content=0;URL=register.php>";
exit();
}
if(trim($_POST["tele_teacher"]) == "")
{
echo "<script> alert('กรุณากรอกเบอร์โทรศัพท์!')</script>";
print "<meta http-equiv=refresh content=0;URL=register.php>";
exit();
}
if(trim($_POST["add_tele"]) == "")
{
echo "<script> alert('กรุณากรอกช่องต่อ')</script>";
print "<meta http-equiv=refresh content=0;URL=register.php>";
exit();
}
if(trim($_POST["email_teacher"]) == "")
{
echo "<script> alert('กรุณากรอกอีเมล!')</script>";
print "<meta http-equiv=refresh content=0;URL=register.php>";
exit();
}
else
{
$strSQL = "INSERT INTO teacher (name_teacher,room_teacher,tele_teacher,add_tele,email_teacher)
VALUES ('".$_POST["name_teacher"]."', '".$_POST["room_teacher"]."','".$_POST["tele_teacher"]."',
'".$_POST["add_tele"]."','".$_POST["email_teacher"]."')"
or die (mysql_error($strSQL));
$objQuery = mysql_query($strSQL);
echo "<script> alert('เพิ่มอาจารย์นิเทศแล้ว ')</script>";
echo "<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><center><img src='icon/ajax-loader.gif' width='50' height='50' /></center>";
print "<meta http-equiv=refresh content=0;URL=admin_page_add_teacher.php>";
}
mysql_close();
?>
มัน echo เพิ่มอาจานย์นิเทศแล้ว
แต่ไม่ลงฐานข้อมูล
ฐานข้อมูลที่เก็บครับ
Code (PHP)
--
-- โครงสร้างตาราง `teacher`
--
CREATE TABLE `teacher` (
`id_teacher` int(5) NOT NULL auto_increment,
`name_teacher` varchar(100) NOT NULL,
`room_teacher` varchar(20) NOT NULL,
`tele_teacher` varchar(10) NOT NULL,
`add _tele` varchar(10) NOT NULL,
`email_teacher` varchar(40) NOT NULL,
PRIMARY KEY (`id_teacher`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
Tag : PHP

|
|
 |
 |
 |
 |
Date :
2012-08-01 05:51:12 |
By :
B[O]YA |
View :
1024 |
Reply :
3 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (PHP)
$objQuery = mysql_query($strSQL) or die(mysql_error());
เอา Error มาดูครับ
|
 |
 |
 |
 |
Date :
2012-08-01 06:42:40 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
หลังจากใส่ Code (PHP)
$objQuery = mysql_query($strSQL) or die(mysql_error());
มันก็ได้เฉยเลยยย งง มากก      
|
 |
 |
 |
 |
Date :
2012-08-01 13:37:35 |
By :
B[O]YA |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|

|
 |
 |
 |
 |
Date :
2012-08-01 20:47:28 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 01
|