|
ดู Error ให้หน่อยครับ (ภาค 2)
คือผมต้องการจะแก้ไขข้อมูลใน mysql ผ่าน ฟอร์มของ php แต่มัน error อย่างเงี่ยครับ เวลารัน +++++ You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 +++++ และนี้คือตัวอย่าง โค๊ดครับ ไฟล์แรกชื่อว่า edit1.php ดังนี้ ++++++++++
<? Require('dbconnect_test.php');
mysql_connect( $host,$username,$password) or die ("ติดต่อกับฐานข้อมูล Mysql ไม่ได้ "); mysql_select_db($db) or die("เลือกฐานข้อมูลไม่ได้");
$sql= "Select * From $tb"; $result=mysql_db_query($db,$sql); $count=mysql_num_rows($result); if(empty($count)) /* ตรวจสอบข้อมูลในฐานข้อมูล */ { echo"<center><br> ไม่พบข้อมูล <b><a href=# onclick ='history.back()'>กลับไปป้อนข้อมูลใหม่</a> </center>"; exit(); } else { ?> <div align="center"> <? echo " แสดงรายการทั้งหมด $count</b> Reccord "; ?> <br><br> </div> <table width="50%" border="1" align="center"> <tr> <td width="5%"> <div align="center">id</div></td> <td width="9%"><div align="center">name</div></td> <td width="5%"><div align="center">แก้ไข</div></td> </tr> </table> <? $a=0; while($a < $count) { $rec = mysql_fetch_array($result); $id=$rec["id"]; $name=$rec["name"];
?> <table width="50%" border="1" align="center"> <tr><td width="5%"><div align="center"><?echo"$id";?></div></td> <td width="9%"><div align="center"><?echo"$name";?></div></td>
<td width="5%"><a href="edit2.php?id=<?echo "$id"; ?>">edit</a></td> </tr> </table> <? $a++; }} mysql_close(); echo"<center><br><a href=# onclick ='history.back()'>กลับรายการ</a> </center>"; ?> +++++++
จากคุณ :
New_php
-[
28 ส.ค. 51 - 16:20:44
A:118.172.34.224 X:
]
|