February 23rd, 2000, 08:20 PM
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.
February 23rd, 2000, 09:35 PM
Convert the special characters to their HTML equivalents.
February 24th, 2000, 09:30 AM
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
b4 your insert stmt
February 24th, 2000, 01:06 PM
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.
February 24th, 2000, 01:12 PM
<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).]
February 24th, 2000, 02:12 PM
MySQL using the backslash to escape, not the tick.
February 24th, 2000, 03:58 PM
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?
[This message has been edited by TroutMask (edited February 24, 2000).]
February 25th, 2000, 05:50 PM
I must have missed the AddSlashes and StripSlashes. Of course, now I'll have to go back and rewrite those parts of my code.
February 28th, 2000, 02:00 PM
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?