The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Programming Languages
> PHP Development
|
How to store name such as O'Keefe
Discuss How to store name such as O'Keefe in the PHP Development forum on Dev Shed. How to store name such as O'Keefe PHP Development forum discussing coding practices, tips on PHP, and other PHP-related topics. PHP is an open source scripting language that has taken the web development industry by storm.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

February 23rd, 2000, 08:20 PM
|
|
Registered User
|
|
Join Date: Nov 1999
Posts: 9
Time spent in forums: < 1 sec
Reputation 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
|

February 23rd, 2000, 09:35 PM
|
|
Contributing User
|
|
Join Date: Oct 1999
Location: SLC, UT, USA
Posts: 47

Time spent in forums: < 1 sec
Reputation Power: 14
|
|
|
Convert the special characters to their HTML equivalents.
|

February 24th, 2000, 09:30 AM
|
|
Contributing User
|
|
Join Date: Apr 1999
Location: London
Posts: 110
Time spent in forums: 22 m 26 sec
Reputation 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
|

February 24th, 2000, 01:06 PM
|
|
Junior Member
|
|
Join Date: Feb 2000
Location: durham, nc, usa
Posts: 14
Time spent in forums: < 1 sec
Reputation 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.
|

February 24th, 2000, 01:12 PM
|
|
Junior Member
|
|
Join Date: Feb 2000
Location: durham, nc, usa
Posts: 14
Time spent in forums: < 1 sec
Reputation 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).]
|

February 24th, 2000, 02:12 PM
|
|
Apprentice Deity
|
|
Join Date: Jul 1999
Location: Niagara Falls (On the wrong side of the gorge)
Posts: 3,237

Time spent in forums: 4 m 8 sec
Reputation Power: 17
|
|
|
jodonnell,
MySQL using the backslash to escape, not the tick.
|

February 24th, 2000, 03:58 PM
|
|
Contributing User
|
|
Join Date: Feb 2000
Location: Englewood, CO
Posts: 30
Time spent in forums: < 1 sec
Reputation Power: 14
|
|
|
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).]
|

February 25th, 2000, 05:50 PM
|
|
Contributing User
|
|
Join Date: Oct 1999
Location: SLC, UT, USA
Posts: 47

Time spent in forums: < 1 sec
Reputation Power: 14
|
|
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.
|

February 28th, 2000, 02:00 PM
|
|
Contributing User
|
|
Join Date: Oct 1999
Location: SLC, UT, USA
Posts: 47

Time spent in forums: < 1 sec
Reputation Power: 14
|
|
|
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
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|