> 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...

PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to