 |
You have an error in your SQL syntax; แก้ไขยังไงดีครับ เปลี่ยนเวอร์ชั่นแล้วเป็นครับ ? |
|
 |
|
|
 |
 |
|
มันขึ้นแบบนี้ แก้ไขยังไงครับ
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 'overflow: hidden; border: 0; width: 800px; height: 600px' src='http://embed.clou' at line 2
อันนี้โค้ดของหน้านี้ครับ
Code (PHP)
<?php
$host="localhost"; // กำหนด host
$username=" "; // กำหนด username
$pass_word=" "; // กำหนด Password
$db="moviescity_dlast"; // กำหนดชื่อฐานข้อมูล
$Conn = mysql_connect($host,$username,$pass_word) or die ("ติดต่อฐานข้อมูลไม่ได้");// ติดต่อฐานข้อมูล
mysql_query("SET NAMES utf8",$Conn); // set กำหนดมาตราฐาน utf8
mysql_select_db($db) or die("เลือกฐานข้อมูลไม่ได้"); // เลือกฐานข้อมูล
//--->
$name = $_POST['name'];
$m_tag = $_POST['m_tag'];
$quality = $_POST['quality'];
$m_pic = $_POST['m_pic'];
$tr_m = $_POST['tr_m'];
$object = $_POST['object'];
$details =$_POST['details'];
$class =$_POST['class'];
$name_user =$_POST['name_user'];
// เพิ่มลงฐานข้อมูล
$sql_add ="insert into M_movies set
name = '$name' , m_tag = '$m_tag' , quality = '$quality' , tr_m = '$tr_m' , m_pic = '$m_pic' , object = '$object' , details = '$details' , name_user = '$name_user' , class = '$class' ";
mysql_query($sql_add) or die(mysql_error());
echo "เพิ่มหนังเรื่อง $name สำเร็จแล้วครับ <a href='addword.php' target=_self>ย้อนกลับ </a> ";
//-->
?>
Tag : PHP, Ms Access, HTML/CSS, JavaScript, CakePHP
|
|
 |
 |
 |
 |
Date :
2015-03-05 11:29:25 |
By :
dlast |
View :
705 |
Reply :
8 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
echo $sql_add; มาดูเต็มๆ หน่อยครับ
น่าจะเป็นตรงนี้
src='http://embed.clou
เป็น
src=''http://embed.clou
สีแดง single quote 2 ตัวนะครับ อย่าลืม ตัวหลังด้วยครับ
src =''.....''
ปล. อีกที ใช้ mysql_real_escape_string( $data );
$xdata = mysql_real_escape_string( $data );
Code (PHP)
$sql = <<<SQL
insert into table set field = '$xdata'
SQL;
|
ประวัติการแก้ไข 2015-03-05 11:33:22 2015-03-05 11:35:37
 |
 |
 |
 |
Date :
2015-03-05 11:31:17 |
By :
Chaidhanan |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
insert into M_movies set name = 'The Pyramid (2014)' , m_tag = 'Horror' , quality = 'คมชัดระดับ HD' , tr_m = ' ' , m_pic = 'http://uppic.thaibuzz.com/it/thepyramid.jpg' , object = ' ' ,
details = '
A team of U.S. archaeologists unearths an ancient pyramid buried deep beneath the Egyptian desert. As they search the pyramid’s depths, they become hopelessly lost in its dark and endless catacombs. Searching for a way out, they become desperate to seek daylight again. They come to realize they aren’t just trapped, they are being hunted.'
, name_user = 'webmaster' , class = 'non'
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 'playerZhnckRqUobPt'>
echo ตอนใส่ข้อมูลเข้าฐานข้อมูล แล้วขึ้นแบบนี้ครับ
|
 |
 |
 |
 |
Date :
2015-03-05 11:39:35 |
By :
dlast |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
details = '
A team of U.S. archaeologists unearths an ancient pyramid buried deep beneath the Egyptian desert. As they search the pyramid’s depths, they become hopelessly lost in its dark and endless catacombs. Searching for a way out, they become desperate to seek daylight again. They come to realize they aren’t just trapped, they are being hunted.'
สีแดง มัน single quote ที่ไม่ได้ escape code ไว้ครับ
|
 |
 |
 |
 |
Date :
2015-03-05 12:00:22 |
By :
Chaidhanan |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ผมไม่รู้ว่าแรกๆ มันผ่านมาได้ยังไง ถ้าไม่ใช้ addslashes หรือ mysql_real_escape_string
เพราะ มันต้องผิดไวยกรณ์ ถ้าใส่เข้าไปตรงๆ น่ะครับ
จะ version ไหน พื้นฐานตรงนี้เหมือนกันหมดครับ
|
 |
 |
 |
 |
Date :
2015-03-05 12:34:33 |
By :
Chaidhanan |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ใช้ addslashes( $string) ก็ได้ครับ
หรือให้ดี mysql_real_escape_string($string)
|
 |
 |
 |
 |
Date :
2015-03-05 12:54:11 |
By :
Chaidhanan |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|