On Mar 12, 2004, at 11:24 PM, Pablo Gosse wrote:
David Westbrooks wrote:
I have articles held in a MySQL database for a law firm. When I pull
the information from the DB and display it, words like "that's" are
shown as "that\'s". To take care of this problem I have done this:
$newsart = eregi_replace("\\\'","'", $newsart);

Is there a better way to handle this to catch all irregular
characters?
<snip>

http://www.php.net/stripslashes

stripslashes() is, like Pablo said, the solution to your question. But you should not ask how to remove the slashes, but why they are there.


You should read the excellent article by Jeffrey Siegel and Michael Southwell in PHP Magazine 2.04 about 'Storing and displaying data', which explains some elementary stuff about this issue. I suppose that 'magic_quotes' (http://www.php.net/manual/en/ref.info.php#ini.magic-quotes-gpc) is switched on on your database server, which is a bad thing.

Since you are using MySQL you should store your data using mysql_real_escape_string() (http://www.php.net/mysql_real_escape_string). This way you won't have to bother with slashes inside of your data.

I would suggest to study the manual carefully on this issue, since it relates with security and possible SQL injection (and we don't want that, do we?).

Regards,

Filip de Waard

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to