i want to update my database with new html code this it the query:
UPDATE `Pages` SET `content`= \'
-
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>')
讨论(0)
-
This could be duplicate of this post
in any case... this could be the solution for you
$html = mysql_real_escape_string($html);
$sql = "UPDATE `Pages` SET `content`= $html";
讨论(0)
-
I think there should be a (') single Quote into your string.
You can use the 'htmlspecialchars' function with ENT_QUOTES as second argument.
And also 'mysql_real_escape_string' function can be used.
Like
$hcode = '<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>';
$hcode = htmlspecialchars($hcode, ENT_QUOTES);
UPDATE `Pages` SET `content`= '$hcode';
讨论(0)
-
Try this:-
$htmlcode = mysql_real_escape_string($htmlcode);
For example:-
$htmlcode = '<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>';
$htmlcode = mysql_real_escape_string($htmlcode);
UPDATE `Pages` SET `content`= '$htmlcode';
讨论(0)
-
store your html content in one variable and use addslashes() when you are inserting it to database.
$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>';
and write your query as below
UPDATE `Pages` SET `content`=addslashes($content);
Hope this will help you :)
讨论(0)
-
I assume this will do the trick
Encode your text
when you get the text back from the database just decode it back
讨论(0)