View Single Post

  #15 (permalink)  
Old 03-28-2008
Lars Eighner
 
Posts: n/a
Default Re: addslashes/mysql_real_escape_string

In our last episode, <47ec1aef$0$90266$14726298@news.sunsite.dk>, the lovely
and talented ndlarsen broadcast on comp.lang.php:

> If I run mysql_real_escape_string() on a string prior to inserting it
> into a database/table, it is submitted to the database modified (with
> backslashes escaping special characters). If I retrieve that same string
> from the database/table, it is still modified and I need to strip the
> string of the backslashes, perhaps with stripslashes()?


No. The database will handle this. One of the reasons
mysql_real_escape_string requires a database link is so that it can properly
escape the string in light of the database character set.
Mysql_real_escape_string provides data in a form the database can understand.
In fact, the database stores that data by a somewhat different escape
scheme and undoes its escapes when it returns data.

--
Lars Eighner <http://larseighner.com/> usenet@larseighner.com
Countdown: 298 days to go.
Reply With Quote