Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

Coding Forum


You are currently viewing our Coding Forum as a guest. Please register to participate.
Login



Reply
', ", \, etc in values... inserting into MySQL
Old 08-05-2003, 11:40 PM ', ", \, etc in values... inserting into MySQL
Skilled Talker

Posts: 99
Trades: 0
What is the best way to handle this?

If a script that requires data with these characters to be inserted into MySQL, and it would be used on various servers with various configurations, what would be the best method to handle it?

Currently, all I can think of is:

PHP Code:

// METHOD 1
addslashes(stripslashes($_POST['value'])) 
// Original... but I have NEVER seen anything like this used hehe

// METHOD 2
ini_set("magic_quotes_gpc"1)
// magic_quotes_gpc can be ineffective in the sense that it addslashes to ALL data... I've never seen slashes in numbers... :)
// Also, some server configurations may not allow this to be set at run time... 
Sooooo.... suggestions please!?
__________________

Please login or register to view this content. Registration is FREE
- Professional PHP mailing list manager
EXHAUSTIVE list of new & improved features implemented!

Please login or register to view this content. Registration is FREE
KandieMan101 is offline
Reply With Quote
View Public Profile Visit KandieMan101's homepage!
 
 
Register now for full access!
Old 08-07-2003, 07:36 PM
Novice Talker

Posts: 7
Location: Utah
Trades: 0
The only characters that need to be replaced are " ' \ and NULL characters. On my site I use
$string = str_replace("\","\\",$string);
$string = str_replace(""","\"",$string);
$string = str_replace("'","\'",$string);

although it's not perfect, it gets the job done.
__________________
--
Jason Jones
DAZ3D Webmaster
DAZ3D Webmaster is offline
Reply With Quote
View Public Profile Visit DAZ3D Webmaster's homepage!
 
Reply     « Reply to ', ", \, etc in values... inserting into MySQL
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.27361 seconds with 12 queries