[thelist] regexp question

sbeam sbeam at syxyz.net
Tue Jul 13 17:54:09 CDT 2004


On Tuesday 13 July 2004 03:22 pm, Alex Beston wrote:
> in my php code the above works ok but it adds a couple of "\" to the
> source eg
>
> <A href=\"blah.html\">
>
> how do i get the "\"'s out so that i have just
>
> <A href="blah.html">

The slashes are probably coming from PHP's input processing operation 
that tries to be "helpful" by backslash-escaping quotes in all incoming 
Get/Post/Cookie strings -
http://us4.php.net/manual/en/ref.info.php#ini.magic-quotes-gpc

Best thing is to turn this config value off to avoid the headache 
forever. It's in php.ini, if you are on Apache you can also use 
a .htaccess file. 

If you can't do that then stripslashes() will work as suggested, but its 
hard to remember all the time when to use it and when not, its better 
IMO to be in the habit of adding the slashes yourself (addslashes()) 
when you need to put user input directly into SQL statements (which 
shouldn't be very often, ideally, but thats a different topic...)

-- 

# S Beam - Web App Dev Servs
# http://www.onsetcorps.net/


More information about the thelist mailing list