Re: question

From: Date: Mon, 16 Dec 2002 16:45:54 +0000
Subject: Re: question
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-128424@lists.php.net to get a copy of this message
> I've got a question about the echo function. If I have a variable (string) > with a in it, and I use echo, the output is \ instead. This I > use this > in a form (if people fill in the form incorrectly, they get the form > again, with the values they entered filled in) and it looks rather weird > when a ' used in a textline becomes a \` when they get the form again. (In > between, I have $comment = preg_replace ("[\']","`",$comment).) > Besides, > when they resubmit the form, the \ is kept and when they get the form for > the third time, it thus becomes \\` - kind of messy :) ... So, what do I > do? Is there a way I can use echo without having it translate to > \? And > what do other people do to replace ' in strings (I can't have them because > I use mySQL to store the data). PHP is adding those escape slashes to your quotes because magic_quotes_gpc is on in your php.ini. That is the default setting and makes it so that if you use those variable directly in a database query, you'll be safer from SQL injection. You can remove the with the stripslashes() function. You'll need to use that function to re-display the user entered data back into a form. On a side note, you should be getting an error from your preg_replace function as your search pattern is not correctly formed. ---John Holmes...

« previous php.general (#128424) next »