Results 1 to 4 of 4

Thread: Storing special characters in MySQL

  1. #1
    Join Date
    May 2007
    Location
    England, UK
    Posts
    235
    Thanks
    3
    Thanked 6 Times in 6 Posts

    Question Storing special characters in MySQL

    I need to store special characters in a MySQL database e.g. "

    If I then call that field using PHP everything after the " is missing.

    I've tried entering a backslash e.g. \" straight into the database but when calling that it just displays \\

    Do i need to use a PHP function to make this work or do I need to edit the database directly?

    Any Ideas?

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Use mysql_real_escape_string() to convert the string to one safe to use in a MySQL query.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  3. #3
    Join Date
    May 2007
    Location
    England, UK
    Posts
    235
    Thanks
    3
    Thanked 6 Times in 6 Posts

    Default

    The special characters are already stored in the database; the problem comes when calling them, do I still need that function? If so where would I place it in this example?

    e.g.

    PHP Code:
    while($info mysql_fetch_array$result )) 
              {
              print 
    $info['row'];
              } 

  4. #4
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Oh, I see, try stripslashes() instead. Sounds like magic quotes.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

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
  •