Cheryl Lander
asked on
php wont update if content has a '
Ive got a form which uses fckeditor.
It works fine but when I add text (content) to the form it wont update if the content has
and apostrophe in it.
Naturally Im going to need to add apostrophes in the contents website so how do I get around this.
It works fine but when I add text (content) to the form it wont update if the content has
and apostrophe in it.
Naturally Im going to need to add apostrophes in the contents website so how do I get around this.
you cannot use the ' in your code when dealing with the fckeditor
ASKER
So what options do i have?
use \"
remember this is in your code ppl can use ' in the fckeditor
remember this is in your code ppl can use ' in the fckeditor
ASKER
dont really follow.
ASKER
I find it hard ot believe that you couldt write the following in fckeditor.
today I can't find a html editor.
If so are there any alternatives?
today I can't find a html editor.
If so are there any alternatives?
ASKER
Ive just gone onto the fckeditor site and done a test on their demo. It works fine.
<p>' "</p>
<br />
So I can only assume its a php code error when inserting it into the database.
<p>' "</p>
<br />
So I can only assume its a php code error when inserting it into the database.
Hi,
It is simple issue,
you need to replace ' ..
after receiving the text from fckeditor, you have to use replace function to replace the ' to `
It is simple issue,
you need to replace ' ..
after receiving the text from fckeditor, you have to use replace function to replace the ' to `
$fcktext = $_POST['fckeditor'];
$formatt_text = str_replace($fcktext, "'","`");
ASKER
logudotcom:
not sure where to make this change.
I have my form page, then I have my processing page (insert)
not sure where to make this change.
I have my form page, then I have my processing page (insert)
you have to make in the processing page...
where you are receiving and insert?
where you are receiving and insert?
if u can, post some code on the processing page, i will modify it?
one more suggestion,
even you can apply this function -->mysql_escape_string()
instead of str_replace(),
even you can apply this function -->mysql_escape_string()
instead of str_replace(),
<?php
$item = "Zak's Laptop";
$escaped_item = mysql_escape_string($item);
printf("Escaped string: %s\n", $escaped_item);
?>
ASKER
Form page.
<tr>
<td valign="top"><div align="right" class="textstandard">
<div align="left">Information<s pan class="textRecord"></span> </div>
</div> </td>
<td valign="top" class="textstandard"><img src="images/icon_circlearr ow.gif" width="11" height="11" /></td>
<td><textarea id="MyTextarea" name="ud_content"><? echo $row["content"]; ?></textarea></td>
</tr>
-------------------------- ---------- ---------- ---------- ---------- ------
Processing page.
$query="UPDATE pages SET content='$ud_content' WHERE pageid='$ud_pageid'";
<tr>
<td valign="top"><div align="right" class="textstandard">
<div align="left">Information<s
</div> </td>
<td valign="top" class="textstandard"><img src="images/icon_circlearr
<td><textarea id="MyTextarea" name="ud_content"><? echo $row["content"]; ?></textarea></td>
</tr>
--------------------------
Processing page.
$query="UPDATE pages SET content='$ud_content' WHERE pageid='$ud_pageid'";
ASKER
note I have other form fields but this is the fckeditor form.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I went into it and added a ' to the content and processed the code and came back to view an nothing had changed.
ASKER
All ok recoded the page and it works great.
Thanks so much.
Thanks so much.
actually, mysql_escape_string() will help you to safer insert/update... it won't replace '
do u need any help again?
ASKER
ok so if you think its better.
Do you want me to open up another question?
actually, mysql_escape_string() will help you to safer insert/update... it won't replace '
Do you want me to open up another question?
actually, mysql_escape_string() will help you to safer insert/update... it won't replace '
may be, you can open new question
ASKER
done.