|
 |
|
Add/Insert Record แล้ว Error ช่วยทีครับ (มือใหม่ อิอิ) |
|
 |
|
|
 |
 |
|
คือผมสร้างตารางมา 3 ตารางได้แก่ Ipaddress ,Namecom ,Description โดยผมจะทำการเพิ่มข้อมูลทั้ง 3 ลงในช่องกรอกแบบฟอร์มที่สร้างขึ้น ผมลองทำตาม https://www.thaicreate.com/php/php-mysql-add-insert-record.html แล้วแต่มันขึ้น Error หน่ะครับ ผมต้องแก้ไขหรือเพิ่มอะไรตรงไหนบ้างหรอครับ ขอบคุณมากๆครับ thaicreate
------------------------------------ ในส่วนของ from -------------------------------------------
<form action="phpMySQLAddSave.php" name="frmAdd" method="post">
<table width="600" border="1">
<tr bgcolor="#33FF33">
<th width="136"> <div align="center">IP Address </div></th>
<th width="287"> <div align="center">Name Computer</div></th>
<th width="355"> <div align="center">Description </div></th>
</tr>
<tr>
<td><div align="center">
<input name="txtIpaddress" type="text">
</div></td>
<td><input name="txtNamecom" type="text" value="" size="50"></td>
<td><input name="txtDescription" type="text" value="" size="100"></td>
</tr>
</table>
<input type="submit" name="submit" value="submit">
</form>
---------------------------------------- ในส่วน Save from ----------------------------------------------------------------
<?
$objConnect = mysql_connect("localhost","root","11223344") or die("Error Connect to Database");
$objDB = mysql_select_db("mydatabase");
$strSQL = "INSERT INTO computeripname ";
$strSQL .="(Ipaddress ,Namecom,Description) ";
$strSQL .="VALUES ";
$strSQL .="('".$_POST["txtIpaddress"]."','".$_POST["txtNamecom"]."','".$_POST["txtDescription"]."' ";
$objQuery = mysql_query($strSQL);
if($objQuery)
{
echo "Save Done.";
}
else
{
echo "Error Save [".$strSQL."]";
}
mysql_close($objConnect);
?>
--------------------------------------------- ในส่ของ code Error ----------------------------------------------------
Error Save [INSERT INTO computeripname (Ipaddress ,Namecom,Description) VALUES ('192.168.0.10','Computernetworksureeporn','คอมพิวเตอร์ฝ่ายต่างๆ ' ]
Tag : PHP, MySQL

|
|
 |
 |
 |
 |
Date :
2013-08-24 12:16:03 |
By :
มือใหม่มากๆ |
View :
613 |
Reply :
1 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ตัวไหนคีไพรมารีคีครับ ตามที่ดู txtIpaddress จะเป็นไพรมารีไม่ได้นะครับโอกาศซ้ำมี . . . . .แก้ใขปัญหาโดยเปิด id ขึ้นมาตัวขึ้นกำหนดเป็น[ไพรมารีคีย์] [auto increment] [int] และก็ไม่ต้องทำอะไรกับโค้ดนี้ให้ลองไปรันดูครับผม
|
 |
 |
 |
 |
Date :
2013-08-24 12:30:41 |
By :
meannerss |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 01
|