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
How to prevent MySQL injection attacks?
Old 11-23-2008, 03:34 PM Re: How to prevent MySQL injection attacks?
Junior Talker

Posts: 1
Trades: 0
Quote:
Originally Posted by drew22299 View Post
I want to allow users to enter their location in their profile but I don't want to allow symbols or MySQL queries.

I entered the following: Bristol^&*^

using the following code:

Code:
 
$location = stripslashes($_POST['location']);
$location = serialize($location);
And the output stored in the database was:

s:11:"Bristol^&*^";

Your explanations are good but I still don't know how to prevent MySQl injection attacks other than use mysql_real_escape_string() What exactly do I need to stop MySQL code entered by a user executing?

Thanks,

This seems a little nuts for whats going on here, If you want someone's name without all the extra crap, why not something like this..

Code:
function letters_spaces($string) 
{ 
   return ereg_replace("[^[:space:]A-Za-z]", "", $string); 
}

$cleanname = letters_spaces($_POST['dirtyname']);

echo $cleanname;
outputs sBristol

Maybe i'm wrong, but that's what I'd try..
cmnetworx is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Reply     « Reply to How to prevent MySQL injection attacks?

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.25006 seconds with 11 queries