2016-08-18 6 views
1

CKEditorからコードスニペットをアップロードできません。それらはうまくフォーマットされますが、データベースにアップロードするときには、テキストをコードとして表示し、一度 '$'変数を押すと停止します。 これは、コードスニペットCKEditorアップロードコードスニペット - SQLエラー

ためのCKEditorバージョンから出力され、これはデータベース

$date = date('Y-m-d') ."\n"; 
 
$now = time(); $utc_time = $now - intval(date('Z', $now)); 
 
$time = date('H:i:s', $now); 
 

 
$name = $_POST['title']; 
 
$subject = $_POST['subject']; 
 

 
$forum_id = $_POST['forum_id']; 
 
$post = $_POST['post']; 
 

 

 
$user_id = $_SESSION['user']['user_id']; 
 
$sql = "INSERT INTO threads (forum_id,user_id,name,post,time,date,subject) VALUES ('$forum_id','$user_id','$name','".$post."','$time','$date','$subject');";

とエラーに投稿するために使用いただきましたですis:

(!) Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42000]: Syntax error or access violation: 1064 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 'echo $hello' in /storage/www/fsociety/newthread.php on line 72 
 
(!) PDOException: SQLSTATE[42000]: Syntax error or access violation: 1064 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 'echo $hello' at line 1 in /storage/www/fsociety/newthread.php on line 72

+0

ようなHTMLをエンコードする必要がありますか? http://stackoverflow.com/questions/21866339/fatal-error-uncaught-exception-pdoexception-with-message-sqlstate42000 http://stackoverflow.com/questions/16367445/uncaught-exception-pdoexception-with-message-sqlstate42000 -syntax-error-or – Lokesh

+0

[HTMLエンティティのエンコード]の可能な複製(http://stackoverflow.com/questions/15713449/encode-html-entities) –

答えて

1

保存する前に、あなたが尋ねる前にそれを確認しました。この

$post = mysql_real_escape_string($_POST['post']);