Closed Thread Icon

Topic awaiting preservation: PHP special chars (Page 1 of 1) Pages that link to <a href="http://ozoneasylum.com/backlink?for=12443" title="Pages that link to Topic awaiting preservation: PHP special chars (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: PHP special chars <span class="small">(Page 1 of 1)</span>\

 
GRUMBLE
Paranoid (IV) Mad Scientist

From: Omicron Persei 8
Insane since: Oct 2000

posted posted 09-23-2002 21:31

ok, im using this code in some dribble scripts i have on the web. e.g. www.embege.com/yearbook

$message=strip_tags($message);
$message=nl2br($message);

then this message gets written into a textfile.
but there special chars like ' and " (and maybe some others) become \' and \".
this is probably because to escape something.

is there a workaround? my head is kinda stuck at the moment. its probably something really simple. thanks.

DL-44
Maniac (V) Inmate

From: under the bed
Insane since: Feb 2000

posted posted 09-23-2002 22:02

If I understand correctly, what you want is stripslashes.



mr.maX
Maniac (V) Mad Scientist

From: Belgrade, Serbia
Insane since: Sep 2000

posted posted 09-23-2002 22:03

PHP has a feature called "magic quotes", which automatically escapes all special characters in all data that's sent to the script (i.e. via GET, POST method, from cookies, etc.) So, the solution to your problem is to either turn off magic quote in php.ini configuration file or to use stripslashes() function to manually unescape strings...


bitdamaged
Maniac (V) Mad Scientist

From: 100101010011 <-- right about here
Insane since: Mar 2000

posted posted 09-23-2002 23:38

The whole stripslashes thing can get to be a real pain in the ass. So be careful with it.

If I'm doing a form that needs to continually send data from page to page I urlencode it once in a hidden field and then urldecode it later. The problem with the stripslashes is that it has no way of discerning slashes it added or ones you have put in so it removes all of them.



.:[ Never resist a perfect moment ]:.

lallous
Paranoid (IV) Inmate

From: Lebanon
Insane since: May 2001

posted posted 09-24-2002 09:22

Grumble, in addition to what mr.Max has said..
you can turn on/off magic quotes per directory basis if you're using apache..

create .htaccess file and put:
php_value magic_quotes_gpc 1




Tyberius Prime
Paranoid (IV) Mad Scientist with Finglongers

From: Germany
Insane since: Sep 2001

posted posted 09-24-2002 11:40

there's also a function called set_magic_quotes_runtime()...

GRUMBLE
Paranoid (IV) Mad Scientist

From: Omicron Persei 8
Insane since: Oct 2000

posted posted 09-24-2002 16:59

thanks everyone.

i think the solution with set_magic_quotes_runtime(1); is probably the easiest.

thanks.

« BackwardsOnwards »

Show Forum Drop Down Menu