Cant read apostrophe from MySql . Strange Problem

Discussion in 'MySQL' started by smart, Jan 19, 2010.

  1. #1
    Hi all,

    I have a strange problem.

    I could successfully insert apostrophe into MySql using mysql_real_escape_string. But when i try to read it to show in input text box it deosn't show. When i check it in database. It has full string with apostrophe.

    Code is : <input type=text name=lecture_name[] value=\''.$row[descr_text].'\'>

    can some one please give me a solution?

    Thanks in advance
    Smart
     
    smart, Jan 19, 2010 IP
  2. jestep

    jestep Prominent Member

    Messages:
    3,659
    Likes Received:
    215
    Best Answers:
    19
    Trophy Points:
    330
    #2
    Are you also using addslashes as well as real_escape...?

    The other probably cause is magic_quotes_gpc is set on, causing the problem.

    Run the function echo get_magic_quotes_gpc(); and see what it returns.
     
    jestep, Jan 19, 2010 IP
  3. smart

    smart Active Member

    Messages:
    232
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    53
    #3
    hi Jestep,

    the function get_magic_quotes_gpc() returns 1.

    Still no idea how to solve this.

    Thank you for the reply.
     
    smart, Jan 19, 2010 IP
  4. jestep

    jestep Prominent Member

    Messages:
    3,659
    Likes Received:
    215
    Best Answers:
    19
    Trophy Points:
    330
    #4
    You need to turn off magic_quotes or use stripslashes().

    Right now, you most likely have slashes stored in the DB, so you probably need to go with the stripslashes method.

    For the future, I would turn off magic_quotes and manually use mysql_real_escape... and other sanitization methods.

    Here's a good description of why not to use magic quotes: http://arpad.co.uk/2008/09/the-adventure-of-php-and-the-magic-quotes/
     
    jestep, Jan 19, 2010 IP