By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,963 Members | 1,834 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,963 IT Pros & Developers. It's quick & easy.

Text box value, backslash, and PHP variable

P: n/a
I have a form with a textbox. On submitting the form I read the
textbox value into a php variable. If the value in the text box
contained a ' or " anywhere in the string, the php variable adds a
backslash ahead of the character. How can I get rid of this unwanted
backslashes?

Thank you
John
Jul 17 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
I noticed that Message-ID:
<1a*************************@posting.google.com> from John contained the
following:
I have a form with a textbox. On submitting the form I read the
textbox value into a php variable. If the value in the text box
contained a ' or " anywhere in the string, the php variable adds a
backslash ahead of the character. How can I get rid of this unwanted
backslashes?


stripslashes()

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 17 '05 #2

P: n/a
Better use a function like this to read your post variables:

function raw_param( $name ) {
return ini_get( 'magic_quotes_gpc' ) ? stripslashes( $name ) : $name;
}

$x = raw_param( $_POST[ 'varname' ] );

This way your script will work regardless of your php setup. If you use
stripslashes() and magic_quotes_gpc is not set by your system
administrator, you may corrupt your input data.

Jul 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.