SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Thread: quoting issues

  1. #1
    SitePoint Zealot p2ranger's Avatar
    Join Date
    Jan 2001
    Location
    Colorado, USA
    Posts
    149
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What exactly does having magic quotes turned on do?
    I assumed that like the name implies, that it is a 'magic' thing that takes care of all quoting issues when it comes to submiting stuff.

    e.g.
    A title like this is entered into a text box
    bob's links of fun

    Now when it is submitted and shown to me for revision it says bob\'s links of fun

    When I submit the info again to make changes, the text box now says
    bob\\\'s links of fun

    I submit it again looking like it is and I get
    bob\\\\\\\'s links of fun

    It is not until this last submission that the slashes actually show up in MySQL. They look like this
    bob\\\'s links of fun

    All the times beforehand, it doesn't show slashes in MySQL.

    So I'm guessing that I need to do addslashes() or stripslashes() somewhere right?

    Thanks

    Jason
    ><>

  2. #2
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Basically magic quotes works for the first time, if there is an error in the submission you would need to use stripslashes($var) before displaying it back into the form. For instance:

    <input type="text" name="name" value="<?stripslashes($name)?>">

    If yo udid this then everytime the form got submitted the slash would be automatically added but if there is an error the form will redisplay the form field with the new escaped value of $name if you do not run stripslashes() you will start to accumulate slashes for each time it errors, does that make sense?
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  3. #3
    SitePoint Zealot p2ranger's Avatar
    Join Date
    Jan 2001
    Location
    Colorado, USA
    Posts
    149
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes! Now I understand. Thanks Freddy

    U da man!

    Jason
    ><>


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
  •