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.

PHP Forum


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



Freelance Jobs

Reply
methods for preventing Mysql Injection
Old 11-21-2010, 04:01 PM methods for preventing Mysql Injection
Skilled Talker

Posts: 77
Name: adam
Location: UK
Trades: 0
what are the best methods for preventing MYSQL injection. I am currently using mysql_real_escape_string however when I look within my database it still excepts all the characters I inputted.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
mintuz is offline
Reply With Quote
View Public Profile Visit mintuz's homepage!
 
 
Register now for full access!
Old 11-21-2010, 04:16 PM Re: methods for preventing Mysql Injection
NullPointer's Avatar
Will Code for Food

Posts: 2,815
Name: Matt
Location: Irvine, CA
Trades: 0
Whenever your dealing with user input make sure you validate it. If you expect the input to be numeric, make sure it is numeric. If you expect the input to be a string you may want to only allow certain characters. After you've done all of that, calling mysql_real_escape_string should be sufficient for preventing sql injections.

A good alternative to using mysql_real_escape_string is to use prepared statements. Look into PDO or mysqli.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
NullPointer is online now
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Old 11-22-2010, 04:22 AM Re: methods for preventing Mysql Injection
Banned

Posts: 408
Name: mushget
Trades: 0
Personally, I don't know all attack victors for MySQL, so I will only comment on Cross Site Scripting

As things stand, if you echo user input to a html page, your site is open to cross site scripting...and possibly cross site forgery, among other attack types.

There are many ways to prevent these attacks such as preventing users from entering any non alphanumerical values including HTML tags, css, etc.
mushget is offline
Reply With Quote
View Public Profile Visit mushget's homepage!
 
Old 11-22-2010, 06:47 AM Re: methods for preventing Mysql Injection
Lashtal's Avatar
wherenomanhasgonebefore

Posts: 680
Name: Lashtal
Trades: 0
aside from mysql_real_escape_string, you might also want to look into htmlentities, add_slashes and (like Nullpointer also noted) apply REGEX (regular expressions) tests for valid input.

also make sure you are sending data through the browser using $_POST as opposed to $_GET in certain instances.
__________________
Currently Reading:
Please login or register to view this content. Registration is FREE
Lashtal is offline
Reply With Quote
View Public Profile
 
Old 11-27-2010, 12:13 AM Re: methods for preventing Mysql Injection
Backslider's Avatar
Experienced Talker

Posts: 40
Trades: 0
I think better to use a library designed and maintained for the purpose, such as Htmlpurifier
Backslider is offline
Reply With Quote
View Public Profile
 
Old 11-27-2010, 05:26 AM Re: methods for preventing Mysql Injection
Extreme Talker

Posts: 156
Trades: 0
One way is to run all data through a function that escapes it with the use of mysql_real_escape_string or mysql_escape_string
dagaul101 is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to methods for preventing Mysql Injection
 

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.30336 seconds with 12 queries