如何使用PHP将HTML代码插入到数据库中
问题描述:
我想用新的html代码更新我的数据库
这就是它的查询:
i want to update my database with new html code this it the query:
UPDATE `Pages` SET `content`= '<div id="intro">
<div id="about" align="left">
<h2 class="bigHeader" dir="rtl"HEADER</h2>
<img src="img/Med-logo.png" alt="" />
<div id="wellcomePage" class="text-left text" dir="rtl">
<p>...some words....</p>
<p>.some words....</p>
<p> </p>
</div>
</div>
</div>'
但是所有的时候我都会收到一个错误。
如何更新我的数据库,我不知道这个html代码里面会有什么,有没有一个函数可以让所有的代码像字符串一样没有特殊符号?
but all the time i get an error. how can i update my database, i don't know what will be inside this html code, is there a function that make all the code like string without special sign?
:
问题与特殊字符一样,'我不能更改html代码,是用户把它放在它。
: the problem is with the special char like ' i can't change the html code, is user chice to put it.
答
请使用 addslashes()
函数进行如下操作,这样可以方便地将更新html插入到
Do following using addslashes()
function, so it will help easily to insert update html to
UPDATE `Pages` SET `content`= addslashes('<div id="intro">
<div id="about" align="left">
<h2 class="bigHeader" dir="rtl"HEADER</h2>
<img src="img/Med-logo.png" alt="" />
<div id="wellcomePage" class="text-left text" dir="rtl">
<p>...some words....</p>
<p>.some words....</p>
<p> </p>
</div>
</div>
</div>')