Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Jun 2012
    Posts
    116
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question writing names with single quote to database

    I have a simple database that keeps track of the songs being played.
    All works well except that when a song name has a single quote, I get an error message.

    I looked at a few things like rawurlencode, which is not what I need.
    str_replace() seems to be the solution, but how do you code it for my needs?
    The php manual does not address this.

    Please move to better forum if needed.

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,801
    Thanks
    160
    Thanked 2,216 Times in 2,203 Posts
    Blog Entries
    1
    The php manual does not address this.
    See http://php.net/manual/en/function.my...ape-string.php
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #3
    Regular Coder
    Join Date
    Jun 2012
    Posts
    116
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Just what I needed.
    Now the file names are being added to the list when it has an ' in the name.
    Thanks.

    Now what's the difference between that and addslashes()?

  • #4
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,978
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    Nothing, for the purpose of a '. Addslashes only works with ', ", \, and \0. The dbms functions escape \x00, \n, \r, \, ', ", and \x1a. This is why stripslashes must be issued on a machine with magic_quotes_gpc enabled, and the proper dbms escaping applied.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •