Forums
This topic is locked
cookie field returns "John\\\'s place" instead of
Posted 22 years ago
1
has voted
22 years ago chris chris posted:
The cookie returns "John\\\'s Place" instead of "John's Place"How do I strip off the \\\ from the string?
Thanks
Replies
Replied 22 years ago
22 years ago Julio Taylor replied:
servers don't generally like single quotes. why don't you remove the single quote from your name and save yourself a whole load of coding and grief?
------------------------
Julio
PHP | MySQL | UD4
ICQ: 19735247
------------------------
Julio
PHP | MySQL | UD4
ICQ: 19735247
Replied 22 years ago
22 years ago Nicholas Bennett replied:
If php is configured with magic_quotes_gpc() set to true then php will automatically escape quotes with a backslash. Which is the same as calling addslashes(). Very usefull for working with db's as unescaped quotes will cause an error in you SQL syntax. The opposite function is stripslashes().
The reason you are returning John\\\'s as far as i know is that b4 you save to the cookie you're not removing the backslashes. So, when php reads the cookie "John\'s" it then escapes the the backslash "\\" so you end up with "John\\\'s"
I might be wrong but at least i try lol
if you just want to strip all the backslashes try something like $cookie_value= preg_replace("/\\+/", "", $cookie_value);
Edited by - nickuk on 09 Feb 2003 08:36:21
The reason you are returning John\\\'s as far as i know is that b4 you save to the cookie you're not removing the backslashes. So, when php reads the cookie "John\'s" it then escapes the the backslash "\\" so you end up with "John\\\'s"
I might be wrong but at least i try lol
if you just want to strip all the backslashes try something like $cookie_value= preg_replace("/\\+/", "", $cookie_value);
Edited by - nickuk on 09 Feb 2003 08:36:21