如何使用PHP将HTML代码插入到数据库中 [英] how to insert HTML code into DB using php

查看:384
本文介绍了如何使用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>&nbsp;</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>&nbsp;</p>
</div>
</div>
</div>') 

这篇关于如何使用PHP将HTML代码插入到数据库中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆