SitePoint Sponsor

User Tag List

Results 1 to 8 of 8

Thread: mySQL and PHP

  1. #1
    SitePoint Member
    Join Date
    Jul 2002
    Location
    Illinois
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question mySQL and PHP

    Greetings:

    I have been working through chapter 6 of Kevin Yank's mySQL and PHP Database Driven Web Site book. I uploaded the chapter 6 example and got it working OK. I have encountered a problem. When pasting (or typing) into the content form I found that I had to escape any single quotes that appeared in my content. At some point in time I would like to turn a modified form over to someone else to post content. Explaining the escape process would be futile. At this point I am a bit lost. Any suggestions would be appreciated.

    Thanks.

    MarkR

  2. #2
    ********* Genius Mike's Avatar
    Join Date
    Apr 2001
    Location
    Canada
    Posts
    5,458
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Run the content of it through addslashes()

    $textbox = addslashes($_POST['textbox']);
    Mike
    It's not who I am underneath, but what I do that defines me.

  3. #3
    Mlle. Ledoyen silver trophy seanf's Avatar
    Join Date
    Jan 2001
    Location
    UK
    Posts
    7,168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Only use addslashes() if magic_quotes_gpc is off, if it's on and you use addslashes() you'll get extra slashes

    For more details see: http://www.sitepointforums.com/showt...threadid=54074

    Sean
    Last edited by seanf; May 13, 2003 at 15:03.
    Harry Potter

    -- You lived inside my world so softly
    -- Protected only by the kindness of your nature

  4. #4
    SitePoint Member
    Join Date
    Jul 2002
    Location
    Illinois
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you. I'll work through these solutions tonight.

  5. #5
    ********* Genius Mike's Avatar
    Join Date
    Apr 2001
    Location
    Canada
    Posts
    5,458
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    If he had to escape the quotes himself, then magic quotes is probably off
    Mike
    It's not who I am underneath, but what I do that defines me.

  6. #6
    Mlle. Ledoyen silver trophy seanf's Avatar
    Join Date
    Jan 2001
    Location
    UK
    Posts
    7,168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    There's absolutely zero chance of him ever changing hosts, or his current host changing changing the config? Plus, if this is on his own computer he's probably using the recommended php.ini (which has magic_quotes_gpc off), whilst his host is more likely to use the standard (which has magic_quotes_gpc on)

    Sean
    Harry Potter

    -- You lived inside my world so softly
    -- Protected only by the kindness of your nature

  7. #7
    ********* Genius Mike's Avatar
    Join Date
    Apr 2001
    Location
    Canada
    Posts
    5,458
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Mike
    It's not who I am underneath, but what I do that defines me.

  8. #8
    SitePoint Member
    Join Date
    Jul 2002
    Location
    Illinois
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Mike Bourne. Thank you. This solution worked!

    $textbox = addslashes($_POST['textbox']);


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
  •