#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 1999
    Posts
    9
    Rep Power
    0
    Hi,

    I need some help on how to store name such as O'Keefe on MYSQL. When I store it from a text input, it get store as OKeefe.

    Thanks,

    Claude
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 1999
    Location
    SLC, UT, USA
    Posts
    47
    Rep Power
    15
    Convert the special characters to their HTML equivalents.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 1999
    Location
    London
    Posts
    110
    Rep Power
    0
    easiest would be to AddSlashes when putting it in and then StripSlashes when reading it out.
    Its in the string fuctions of the php manual

    ie
    $body=addslashes($body);

    b4 your insert stmt

    hth t

    ------------------
    cheers
  6. #4
  7. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2000
    Location
    durham, nc, usa
    Posts
    14
    Rep Power
    0
    Not sure what you're scrip is written in, but you need to replace the single tick in your input with a double tick ('', not ").

    SQL stores this string as a single tick.
  8. #5
  9. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2000
    Location
    durham, nc, usa
    Posts
    14
    Rep Power
    0
    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>ereg_replace("'","''",$string_with_single_quotes);[/code]




    [This message has been edited by jodonnell (edited February 24, 2000).]
  10. #6
  11. No Profile Picture
    Apprentice Deity
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 1999
    Location
    Niagara Falls (On the wrong side of the gorge)
    Posts
    3,237
    Rep Power
    19
    jodonnell,

    MySQL using the backslash to escape, not the tick.
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2000
    Location
    Englewood, CO
    Posts
    30
    Rep Power
    15
    While ' is not technically an escape, you can use '' (TWO SINGLE QUOTES) within a query string to denote a single quote:

    SELECT * FROM some_table WHERE some_column ='Isn''t this nice?'

    will return results where some_column = Isn't this nice?

    -TM


    [This message has been edited by TroutMask (edited February 24, 2000).]
  14. #8
  15. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 1999
    Location
    SLC, UT, USA
    Posts
    47
    Rep Power
    15
    Thanks
    I must have missed the AddSlashes and StripSlashes. Of course, now I'll have to go back and rewrite those parts of my code.
  16. #9
  17. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 1999
    Location
    SLC, UT, USA
    Posts
    47
    Rep Power
    15
    Just thought I'd share this tip. You can also use magic_quotes_gpc and/or enable_magic_quotes. I assume the enable_magic_quotes is a compiler option when building PHP as an Apache module and the magic_quotes_gpc is an Apache directive. Anybody got the real scoop on these two?

    Rob

Similar Threads

  1. Best way to store data
    By valensnow in forum MySQL Help
    Replies: 0
    Last Post: February 16th, 2004, 10:39 PM
  2. help the php newbie store mysql results into an array
    By musikit in forum PHP Development
    Replies: 2
    Last Post: October 28th, 2003, 08:18 AM
  3. store values
    By superman in forum PHP Development
    Replies: 2
    Last Post: July 7th, 2003, 01:58 AM
  4. Replies: 6
    Last Post: January 27th, 2003, 12:16 PM
  5. suggest to store images
    By renato in forum PHP Development
    Replies: 6
    Last Post: July 12th, 2002, 12:45 AM

IMN logo majestic logo threadwatch logo seochat tools logo