replace single and double quotes
| From: | Reinhart Viane | Date: | Tue, 29 Aug 2006 13:16:12 +0000 |
| Subject: | replace single and double quotes | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-241178@lists.php.net to get a copy of this message | ||
This is the code is use to insert/update text into a database field:
$sqledit="update activities set act_extra='$_POST[editextra]',
act_extra_fr='$_POST[editextrafr]' where act_id=$_POST[editid]";
Now both $_POST[editextra] and $_POST[editextrafr] can contain single or
double quotes.
So the query almost always gives me an error.
I know I have to replace " with ", but I do not know how to replace the
single quote so it is shown as a single quote on a webpage when I get it
from the database
I have been looking into str_replace and preg_replace. But what I really
need is a solution that 'replaces' single quotes, double quotes en curly
quotes so I tackle all possible problems and the same text as it was inputed
in the textarea is shown on the webpage.
Thx in advance