 |
แอดข้อมูลไม่ยอมลงดาต้าเบส ทั้งที่อะไรถูกทุกอย่าง ไม่รู้เป็นที่อะไรอะครับ |
|
 |
|
|
 |
 |
|
แอดข้อมูลไม่ยอมลงตารางดาต้าเบส ทั้งที่อะไรถูกทุกอย่าง ไม่รู้เป็นที่อะไรอะครับ
ดาต้าเบสผมมีตารางทั้งที่ลงข้อมูลได้ และก็ลงข้อมูลไม่ได้ ทั้งๆที่ใช้ไฟลการเชื่อมดาต้าเบสincludeมาจากที่เดียวกัน
ฟิลในตารางเป็นชนิดtextทุกตัว
เวลาเอาลงมันจะไปที่dieทุกครั้งเลยครับ
Code (PHP)
$strSQL = "INSERT INTO family";
$strSQL .="(name,content,quatable,lastedit,view,userid,show) ";
$strSQL .="VALUES ";
$strSQL .="('wer','wer','wer','wer','wer','wer','wer')";
$objQuery = mysql_query($strSQL)or die("cannot");
Tag : PHP, MySQL
|
|
 |
 |
 |
 |
Date :
2010-11-26 10:23:31 |
By :
tee |
View :
700 |
Reply :
8 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ลองใช้ mysql_error() ตามที่พี่วินบอก ดูค่ะ จะได้รู้ว่า sql error อะไรหรือเปล่า
$objQuery = mysql_query($strSQL)or die(mysql_error());
|
ประวัติการแก้ไข 2010-11-26 10:32:16
 |
 |
 |
 |
Date :
2010-11-26 10:31:30 |
By :
ultrasiam |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ไม่ได้อะครับ มันขึ้น
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 'show) VALUES ('wer','wer','wer','wer','wer','wer','wer')' at line 1
|
 |
 |
 |
 |
Date :
2010-11-26 10:33:38 |
By :
tee |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
แต่ตารางที่ลงข้อมูลได้ผมก็ใช้โค้ดนี้นะครับ
$objQuery = mysql_query($strSQL)or die("cannot");
งงมากๆทั้งที่โค้ดเหมือนกันแต่ใช้ไม่ได้
|
 |
 |
 |
 |
Date :
2010-11-26 10:36:11 |
By :
tee |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
"show" เป็นคำสงวนค่ะ เปลี่ยนเป็นคำอื่นนะคะ หรือไม่ก็ใส่ ' ' ครอบไว้ แต่เปลี่ยนใหม่ปลอดภัยสุด
อ้างอิง ดูคำสงวนได้จากเว็บนี้ค่ะ
|
 |
 |
 |
 |
Date :
2010-11-26 10:41:17 |
By :
ultrasiam |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ข้อมูลที่ insert กับ type มันตรงกันหรือป่าวครับ
|
 |
 |
 |
 |
Date :
2010-11-26 10:42:12 |
By :
kanchen |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ไม่เกี่ยวกับโค้ดนี้หรอกค่ะ จะใช้แบบนี้ก็ได้
$objQuery = mysql_query($strSQL)or die("cannot");
ที่แนะนำให้ใช้
$objQuery = mysql_query($strSQL)or die(mysql_error());
เพื่อให้มันแสดง error นี้ออกมา จะได้รู้ว่า sql statement ผิดพลาดตรงไหน
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 'show) VALUES ('wer','wer','wer','wer','wer','wer','wer')' at line 1
|
 |
 |
 |
 |
Date :
2010-11-26 10:43:26 |
By :
ultrasiam |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ได้แล้วครับ ขอบคุณมากๆครับ
|
 |
 |
 |
 |
Date :
2010-11-26 10:44:30 |
By :
tee |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|