Thread: Quote Problem

    #1
  1. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Aug 2000
    Location
    Indiana
    Posts
    614
    Rep Power
    16
    Has anybody been able to fix this bug:

    test.php
    <?
    print $test;
    ?>

    then you type:

    test.php?test="asdf"

    and get this:

    "asdf"

    This is a very over simplified version of the problem, but you should get the point. any quotes submitted and then printed on the following page (which mysql processing) always get " to print instead of ".

    Any ideas?
  2. #2
  3. No Profile Picture
    RyanP
    Guest
    Devshed Newbie (0 - 499 posts)
    Doesn't that have something to do with "magic quotes"? I think you can turn it off in your php.ini
  4. #3
  5. No Profile Picture
    Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2000
    Location
    thane
    Posts
    50
    Rep Power
    0
    or if u don't want to put it off for entire domain..

    u can add those magic_quotes off line in
    .htaccess file
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Aug 2000
    Location
    Indiana
    Posts
    614
    Rep Power
    16
    What's the line look like?
  8. #5
  9. No Profile Picture
    Gödelian monster
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Jul 1999
    Location
    Central Florida, USA
    Posts
    2,307
    Rep Power
    62
    It's NOT a bug, it's a feature. (called escaping) It's how you separate text data from executable code. You probably don't want to turn off magic quotes, but actually to turn it on fully. Check out this post http://www.devshed.com/Talk/Forums/F...ML/002641.html

    Or, if you don't want to mess with magic_quotes, you can just use the stripslashes() function to remove the slashes when you publish the data.

  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Aug 2000
    Location
    Indiana
    Posts
    614
    Rep Power
    16
    Yes, we all know by now that it's not a bug. But it is a very annoying "feature." There should be a way to un magic_quote something.
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2000
    Posts
    79
    Rep Power
    15
    what do u want it to print? if u just want it to print...

    asdf

    then go to
    test.php?test=asdf


    Basil
  14. #8
  15. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Aug 2000
    Location
    Indiana
    Posts
    614
    Rep Power
    16
    But if you wanted to print:
    Bill said, "blah."
    then you'd be out of luck. that's where the problem comes in. Anyway, the answer is to use stripslashes();
  16. #9
  17. No Profile Picture
    Gödelian monster
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Jul 1999
    Location
    Central Florida, USA
    Posts
    2,307
    Rep Power
    62
    Yes, but if you read the other post, you'll see what I mean. Most PHP installations by default have magic_quotes_gpc on, but magic_quotes_runtime off. What I think you might want is magic_quotes_runtime on. Check your /usr/local/lib/php.ini file.

    With my configuration, the magic quotes feature works both ways, for input AND output, so you'll never even have to think about it. That's what magic quotes was created for; to make it so you don't have to think about it.
  18. #10
  19. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Aug 2000
    Location
    Indiana
    Posts
    614
    Rep Power
    16
    Oh, I see what you mean.

    Thanks for the advice.
  20. #11
  21. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2000
    Posts
    9
    Rep Power
    0
    use: &amp;quot;blah&amp;quot; or %22blah%22 in your query string

    or

    myVar = urlencode(""blah"");
    and put the contents of myVar in the query string

    [This message has been edited by MyLameNic (edited September 13, 2000).]

    [This message has been edited by MyLameNic (edited September 13, 2000).]
  22. #12
  23. No Profile Picture
    Gödelian monster
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Jul 1999
    Location
    Central Florida, USA
    Posts
    2,307
    Rep Power
    62
    Mea Culpa:

    Oooops... it was actually the OTHER way around: you probably have magic_quotes_runtime turned ON, and this is ADDING quotes to all runtime-generated data, so you need to turn it off.

    See http://www.devshed.com/Talk/Forums/F...ML/002921.html

    I apologize for any misdirection.

Similar Threads

  1. Replies: 5
    Last Post: February 2nd, 2005, 01:28 AM
  2. UTF-8 problem in 4.1.1a
    By mehran20 in forum MySQL Help
    Replies: 1
    Last Post: February 8th, 2004, 03:21 PM
  3. WinNT4 problem
    By sandipguha in forum Windows Help
    Replies: 0
    Last Post: January 27th, 2004, 03:06 AM
  4. weird java problem..please help
    By suwandy in forum Java Help
    Replies: 1
    Last Post: January 26th, 2004, 05:13 AM
  5. Session Variable problem :(
    By modesty in forum PHP Development
    Replies: 1
    Last Post: January 15th, 2004, 05:00 AM

IMN logo majestic logo threadwatch logo seochat tools logo