error ใน php ใครพอทราบบ้าง โปรแกรมแจ้งข้อผิดพลาด mysql_fetch_array():
error ใน php ใครพอทราบบ้าง
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 'between,type,style,height,barrier,detail,detected,status,deadline ,name, address' at line 1
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\AppServ\www\invasion\saveform.php on line 13
หมายความว่ายังไงค่ะ\
Code (PHP)
<?
mysql_connect("localhost","root","1234");
mysql_select_db("invasions");
mysql_query("INSERT INTO invasions invasion_id,month, division,bss,ine,between,type,style,height, barrier,detail, detected,status,deadline ,name, address, telephone,pic)
VALUES('".$_POST['invasion_id']."','".$_POST['month']."','".$_POST['division']."','".$_POST['bss']."','".$_POST['line']."',
'".$_POST['between']."','".$_POST['type']."','".$_POST['style']."','".$_POST['height']."','".$_POST['barrier']."',
'".$_POST['detail']."','".$_POST['detected']."','".$_POST['status']."','".$_POST['deadline']."','".$_POST['name']."',
'".$_POST['address']."','".$_POST['telephone']."','".$_POST['pic']."')");
echo mysql_error();
$i = 1;
$arr = mysql_query("SELECT *FROM invasions");
while($data = mysql_fetch_array($arr)){
echo "<tr>";
echo "<td>".$i."</td>";
echo "<td>".$data['month']."</td>";
echo "<td>".$data['division']."</td>";
echo "<td>".$data['bss']."</td>";
echo "<td>".$data['line']."</td>";
echo "<td>".$data['between']."</td>";
echo "<td>".$data['type']."</td>";
echo "<td>".$data['style']."</td>";
echo "<td>".$data['height']."</td>";
echo "<td>".$data['barrier']."</td>";
echo "<td>".$data['detail']."</td>";
echo "<td>".$data['detected']."</td>";
echo "<td>".$data['status']."</td>";
echo "<td>".$data['deadline']."</td>";
echo "<td>".$data['name']."</td>";
echo "<td>".$data['address']."</td>";
echo "<td>".$data['telephone']."</td>";
echo "<td>".$data['pic']."</td>";
echo "</tr>";
$i++;
}
mysql_close();
?>
Tag : PHP, MySQL
ประวัติการแก้ไข 2011-09-28 14:30:02
Date :
2011-09-28 14:15:01
By :
lookpla26
View :
698
Reply :
5
เอา code มาให้ดูง่ายกว่าเยอะครับ เพราะการ error เกิดจากหลายสาเหตุ
Date :
2011-09-28 14:25:51
By :
grandraftz
บรรทัด 4 จาก
mysql_query("INSERT INTO invasions invasion_id,month, division,bss,ine,between,type,style,height, barrier,detail, detected,status,deadline ,name, address, telephone,pic)
เป็น
mysql_query("INSERT INTO invasions ( invasion_id,month, division,bss,ine,between,type,style,height, barrier,detail, detected,status,deadline ,name, address, telephone,pic)
บรรทัด 9 จาก
'".$_POST['address']."','".$_POST['telephone']."','".$_POST['pic']."')");
เป้น
'".$_POST['address']."','".$_POST['telephone']."','".$_POST['pic']."')") or die(mysql_error());
ลบบรรทัดที่ 11 ออก
บรรทัดที่ 12 เอาไว้ทำอะไรครับ
ถ้า error อะไรอีก เอามาโพสต่อครับ
Date :
2011-09-28 14:51:21
By :
grandraftz
Code (PHP)
<?
mysql_connect("localhost","root","1234");
mysql_select_db("invasions");
mysql_query("INSERT INTO invasions ( invasion_id,month, division,bss,ine,between,type,style,height, barrier,detail, detected,status,deadline ,name, address, telephone,pic)
VALUES('".$_POST['invasion_id']."','".$_POST['month']."','".$_POST['division']."','".$_POST['bss']."','".$_POST['line']."',
'".$_POST['between']."','".$_POST['type']."','".$_POST['style']."','".$_POST['height']."','".$_POST['barrier']."',
'".$_POST['detail']."','".$_POST['detected']."','".$_POST['status']."','".$_POST['deadline']."','".$_POST['name']."',
'".$_POST['address']."','".$_POST['telephone']."','".$_POST['pic']."')") or die(mysql_error());
$i = 1;
$arr = mysql_query("SELECT *FROM invasions");
while($data = mysql_fetch_array($arr)){
echo "<tr>";
echo "<td>".$i."</td>";
echo "<td>".$data['month']."</td>";
echo "<td>".$data['division']."</td>";
echo "<td>".$data['bss']."</td>";
echo "<td>".$data['line']."</td>";
echo "<td>".$data['between']."</td>";
echo "<td>".$data['type']."</td>";
echo "<td>".$data['style']."</td>";
echo "<td>".$data['height']."</td>";
echo "<td>".$data['barrier']."</td>";
echo "<td>".$data['detail']."</td>";
echo "<td>".$data['detected']."</td>";
echo "<td>".$data['status']."</td>";
echo "<td>".$data['deadline']."</td>";
echo "<td>".$data['name']."</td>";
echo "<td>".$data['address']."</td>";
echo "<td>".$data['telephone']."</td>";
echo "<td>".$data['pic']."</td>";
echo "</tr>";
$i++;
}
mysql_close();
?>
ยังขึ้น 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 'between,type,style,height, barrier,detail, detected,status,deadline ,name, addre' at line 1
Date :
2011-09-28 15:41:17
By :
lookpla26
between มัน คำสงวนครับ พยายามอย่าตั้งชือฟิลด์ให้ตรงกับคำสงวน
อันนี้แก้ขัดไปก่อนละกัน วันหลังอย่าตั้งแบบนี้นะครับ `between` ใช้นี่แทน between ไม่ใช่ ' นะ แต่เป็น ` ตรงตัวหนอนนะจ๊ะ
Date :
2011-09-28 15:48:24
By :
ikikkok
Load balance : Server 01