2
我使用的是PDO準備語句插入/更新我的web應用程序一個新的博客文章。除了包含來自WYSIWYG編輯器的HTML標籤的文章主體之外,所有內容都被輸入到數據庫中。
假設$content
包含<p>This is a test article</p>
。它不會使用預先準備的語句插入。但是,如果我不使用準備好的語句,它會插入數據。
我該如何解決這個問題?
這裏是我的查詢:
$SQL = "UPDATE blog_articles SET topic_id = :topic_id, title = :title, ";
$SQL .= "title_slug = :title_slug, description = :description, ";
$SQL .= "keywords = :keywords, content = :content WHERE article_id = :article_id;";
$STH = $DBH->prepare($SQL);
// other binds ...
$STH->bindParam(':content', trim($content));
// other binds ..
$STH->execute();
感謝奔,即工作。不要真的得到bindParam和bindValue的區別 - 更好地開始閱讀! – ShadowStorm
NP。有關於它的討論[這裏](http://stackoverflow.com/questions/1179874/pdo-bindparam-versus-bindvalue),以及指向文檔的鏈接。 –