This is a discussion on Text box value, backslash, and PHP variable within the PHP Language forums, part of the PHP Programming Forums category; I have a form with a textbox. On submitting the form I read the textbox value into a php variable. ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
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 |
|
|||
|
I noticed that Message-ID:
<1ab390bb.0311261529.1ed9978@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/ |
|
|||
|
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. |