PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old February 23rd, 2000, 08:20 PM
cfavre cfavre is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 1999
Posts: 9 cfavre User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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

Reply With Quote
  #2  
Old February 23rd, 2000, 09:35 PM
Robman Robman is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 1999
Location: SLC, UT, USA
Posts: 47 Robman User rank is Private First Class (20 - 50 Reputation Level)Robman User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 14
Convert the special characters to their HTML equivalents.

Reply With Quote
  #3  
Old February 24th, 2000, 09:30 AM
timbo timbo is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 1999
Location: London
Posts: 110 timbo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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

Reply With Quote
  #4  
Old February 24th, 2000, 01:06 PM
jodonnell jodonnell is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2000
Location: durham, nc, usa
Posts: 14 jodonnell User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to jodonnell
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.

Reply With Quote
  #5  
Old February 24th, 2000, 01:12 PM
jodonnell jodonnell is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2000
Location: durham, nc, usa
Posts: 14 jodonnell User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to jodonnell
<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).]

Reply With Quote
  #6  
Old February 24th, 2000, 02:12 PM
rod k rod k is offline
Apprentice Deity
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Jul 1999
Location: Niagara Falls (On the wrong side of the gorge)
Posts: 3,237 rod k User rank is Private First Class (20 - 50 Reputation Level)rod k User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 4 m 8 sec
Reputation Power: 17
Send a message via AIM to rod k
jodonnell,

MySQL using the backslash to escape, not the tick.

Reply With Quote
  #7  
Old February 24th, 2000, 03:58 PM
TroutMask TroutMask is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2000
Location: Englewood, CO
Posts: 30 TroutMask User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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).]

Reply With Quote
  #8  
Old February 25th, 2000, 05:50 PM
Robman Robman is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 1999
Location: SLC, UT, USA
Posts: 47 Robman User rank is Private First Class (20 - 50 Reputation Level)Robman User rank is Private First Class (20 - 50 Reputation Level) 
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.

Reply With Quote
  #9  
Old February 28th, 2000, 02:00 PM
Robman Robman is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 1999
Location: SLC, UT, USA
Posts: 47 Robman User rank is Private First Class (20 - 50 Reputation Level)Robman User rank is Private First Class (20 - 50 Reputation Level) 
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

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPHP Development > How to store name such as O'Keefe

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap