|
 |
|
insert ไม่ลงฐานข้อมูลค่ะ มีการส่งค่าจากที่ผู้ใช้ป้อน แต่พอ insert แล้ว ไม่ได้ค่ะ ช่วยดูโค้ดให้หน่อยนะค่ะ มือใหม่ค่ะ |
|
 |
|
|
 |
 |
|
ไฟล์ add.php
<form id="form1" name="form1" method="post" action="display_add1.php">
<p> </p>
<table width="35%" height="543" border="0" align="center" cellpadding="0" cellspacing="0" bordercolor="#CCCCCC">
<tr>
<td height="38" colspan="2" bgcolor="#FFFFCC"><div align="center">รายละเอียดคำศัพท์ภาษาอังกฤษ</div></td>
</tr>
<tr>
<td width="39%" height="42"><div align="right">รหัสศัพท์อังกฤษ</div></td>
<td width="61%" bordercolor="#CCCCCC"><label><center>
<input type="text" name="txt_id" id="txt_id" />
</center></label></td>
</tr>
<tr>
<td height="55"><div align="right">คำศัพท์ภาษาอังกฤษ</div></td>
<td bordercolor="#CCCCCC"><Label><center><input type="text" name="txt_word" id="txt_word" /></center></Label></td>
</tr>
<tr>
<td height="51" colspan="2" bgcolor="#FFFFCC"><div align="center">
<p>รายละเอียดคำศัพท์ภาษาไทยถิ่น</p>
</div></td>
</tr>
<tr>
<td height="37"><div align="right">รหัสคำศัพท์ภาษาถิ่น</div></td>
<td bordercolor="#CCCCCC"><label><center>
<input type="text" name="rural_id" id="rural_id" />
</center></label></td>
</tr>
<tr>
<td height="38"><div align="right">คำศัพท์ภาษาถิ่น</div></td>
<td bordercolor="#CCCCCC"><label><center>
<input type="text" name="rural_word" id="rural_word" />
</center> </label></td>
</tr>
<tr>
<td height="41"><div align="right">คำอ่าน</div></td>
<td bordercolor="#CCCCCC"><label><center>
<input type="text" name="read" id="read" />
</center></label></td>
</tr>
<tr>
<td height="38"><div align="right">ความหมาย</div></td>
<td bordercolor="#CCCCCC"><label><center>
<input type="text" name="maining" id="maining" />
</center></label></td>
</tr>
<tr>
<td height="42"><div align="right">รหัสคำศัพท์ภาษาอังกฤษ</div></td>
<td bordercolor="#CCCCCC"><label><center>
<input type="text" name="eng_id" id="eng_id" />
</center></label></td>
</tr>
<tr>
<td height="38"><div align="right">ภาค</div></td>
<td bordercolor="#CCCCCC"><label><center>
<select name="select" id="select">
<option value="01">ภาคเหนือ</option>
<option value="04">ภาคกลาง</option>
<option value="02">ภาคใต้</option>
<option value="03">ภาคตะวันออกเฉียงเหนือ</option>
</select>
</center></label></td>
</tr>
<tr>
<td height="60"><div align="right">ไฟล์เสียง</div></td>
<td bordercolor="#CCCCCC"><label><center>
<input type="text" name="sound" id="sound" />
<input type="submit" name="button" id="button" value="Browse" />
</center></label>
<label></label></td>
</tr>
<tr>
<td height="63" colspan="2"><div align="center">
<label></label>
<label><label></label>
</label>
<label>
<input type="submit" name="button2" id="button2" value="บันทึก" />
</label>
<label>
<input type="reset" name="button3" id="button3" value="ยกเลิก" />
</label>
</div></td>
</tr>
</table>
<p> </p>
<p> </p>
</form>
ไฟล์ display_add1.php
<?php
include("connect.php");
$_POST['txt_id'];
$_POST['txt_word'];
echo $_POST['rural_id'];
echo $_POST['rural_word'];
echo $_POST['read'];
echo $_POST['maining'];
echo $_POST['eng_id'];
echo $_POST['select'];
echo $_POST['sound'];
if($_POST['txt_id']!="")
{
$sql="insert into eng(eng_id ,eng_word)values('".$_POST['txt_id']."','".$_POST['txt_word']."')";
$sqlquery=mysql_db_query($dbname, $sql);
}
if($_POST['rural_id']!="")
{
$sql1="insert into rural
(rural_id ,rural_word ,read ,maining ,eng_id ,zone_id,sound_id)
values
('".$_POST['rural_id']."','".$_POST['rural_word']."','".$_POST['read']."','".$_POST['maining']."','".$_POST['eng_id']."','".$_POST['select']."','".$_POST['sound']."')";
$sqlquery1=mysql_db_query($dbname, $sql1);
}
echo "<br> เพิ่มข้อมูลคำศัพท์ลงฐานข้อมูลเรียบร้อยแล้วค่ะ";
mysql_close();
?>
ผลจากการรันออกมาได้แบบนี้ค่ะ
10000000012rfrrfddssereer5e0000000042010000000012
เพิ่มข้อมูลคำศัพท์ลงฐานข้อมูลเรียบร้อยแล้วค่ะ
แต่พอเข้าไปดูในฐานไม่มีค่ะ
รบกวนหน่อยน่ะค่ะพอดีเป้นมือใหม่น่ะค่ะ
Tag : PHP

|
|
 |
 |
 |
 |
Date :
2012-01-16 13:43:10 |
By :
subai |
View :
1128 |
Reply :
4 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
เอาไฟล์ connect มาดูหน่อยครับ
|
 |
 |
 |
 |
Date :
2012-01-16 13:46:09 |
By :
โปรแกรมเมอร์ฝึกหัด |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ไฟล์ connect.php
<?
$host="localhost";
$user="root";
$pass="12345";
$dbname="rural_dic";
echo $link=mysql_connect($host,$user,$pass)or die("ติดต่อฐานข้อมูลไม่ได้");
mysql_select_db($dbname)or die("เลือกฐานข้อมูลไม่ได้");
$charset = "SET NAMES 'tis620'";
mysql_query($charset);
?>
|
 |
 |
 |
 |
Date :
2012-01-16 13:48:04 |
By :
subai |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ทำได้แล้วค่ะ ขอบคุณมากน่ะค่ะที่ช่วยแนะนำค่ะ
|
 |
 |
 |
 |
Date :
2012-01-17 17:04:50 |
By :
subai |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 00
|