Professional Web Applications Themes

Text box value, backslash, and PHP variable - PHP Development

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

  1. #1

    Default Text box value, backslash, and PHP variable

    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
    John Guest

  2. #2

    Default Re: Text box value, backslash, and PHP variable

    I noticed that Message-ID:
    <1ab390bb.0311261529.1ed9978posting.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 [url]http://www.ckdog.co.uk/rfdmaker/[/url]
    Geoff Berrow Guest

  3. #3

    Default Re: Text box value, backslash, and PHP variable

    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.

    Xenofon Papadopoulos Guest

Similar Threads

  1. #39983 [NEW]: writing a backslash in a variable doesn't appear
    By mail at siegfried-bauer dot de in forum PHP Bugs
    Replies: 4
    Last Post: January 9th, 01:31 PM
  2. Replies: 2
    Last Post: November 29th, 05:43 AM
  3. Backslash issue
    By Berry B in forum PHP Development
    Replies: 1
    Last Post: February 19th, 07:41 PM
  4. Replies: 1
    Last Post: September 17th, 02:56 PM
  5. backslash
    By janet in forum ASP
    Replies: 1
    Last Post: August 22nd, 09:56 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139