School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become an Expert!

Join 307,117 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 2,009 people online right now. Registration is fast and FREE... Join Now!




mysql_real_escape_string() or sanitize?

 

mysql_real_escape_string() or sanitize?

dangmnx

16 Aug, 2009 - 11:27 PM
Post #1

D.I.C Head
**

Joined: 10 Apr, 2009
Posts: 248


My Contributions
I've been looking at mysql_real_escape_string() and sanitizing, what are the difference? and which function should i use to prevent against sql injection

mysql_real_escape_string()

or

sanitize ()

This post has been edited by dangmnx: 16 Aug, 2009 - 11:27 PM

User is offlineProfile CardPM
+Quote Post


Wimpy

RE: Mysql_real_escape_string() Or Sanitize?

17 Aug, 2009 - 12:53 AM
Post #2

I feel happy... *singing*
Group Icon

Joined: 2 May, 2009
Posts: 958



Thanked: 132 times
Dream Kudos: 75
My Contributions
There is no native PHP function called sanitize... So definitely mysql_real_escape_string()!

QUOTE(dangmnx @ 17 Aug, 2009 - 09:27 AM) *

I've been looking at mysql_real_escape_string() and sanitizing, what are the difference? and which function should i use to prevent against sql injection

mysql_real_escape_string()

or

sanitize ()


User is offlineProfile CardPM
+Quote Post

ShaneK

RE: Mysql_real_escape_string() Or Sanitize?

17 Aug, 2009 - 04:29 AM
Post #3

require_once("brain.php"); //Fatal error :/
Group Icon

Joined: 10 May, 2009
Posts: 701



Thanked: 47 times
Dream Kudos: 75
Expert In: PHP, MySQL

My Contributions
mysql_real_escape_string is about as safe as you can get your input with mysql_* functions. Sanitize() is a function made by somebody for people who aren't sure if they have the mysql_real_escape_string function, if you don't it uses addslashes (corrected by Wimpy lol), if you do it uses mysql_real_escape_string...I think...I'm not sure, I haven't looked at that function in a while... But if you have it, I'd go with mysql_real_escape_string, since Sanitize() just takes more time (only a little) just checking if it's there or not...

Yours,
Shane~

This post has been edited by ShaneK: 17 Aug, 2009 - 02:39 PM
User is offlineProfile CardPM
+Quote Post

Wimpy

RE: Mysql_real_escape_string() Or Sanitize?

17 Aug, 2009 - 09:18 AM
Post #4

I feel happy... *singing*
Group Icon

Joined: 2 May, 2009
Posts: 958



Thanked: 132 times
Dream Kudos: 75
My Contributions
Almost correct, "it uses stripslashes" should be "it uses addslashes". smile.gif

QUOTE(ShaneK @ 17 Aug, 2009 - 02:29 PM) *

mysql_real_escape_string is about as safe as you can get your input with mysql_* functions. Sanitize() is a function made by somebody for people who aren't sure if they have the mysql_real_escape_string function, if you don't it uses stripslashes, if you do it uses mysql_real_escape_string...I think...I'm not sure, I haven't looked at that function in a while... But if you have it, I'd go with mysql_real_escape_string, since Sanitize() just takes more time (only a little) just checking if it's there or not...

Yours,
Shane~


User is offlineProfile CardPM
+Quote Post

ShaneK

RE: Mysql_real_escape_string() Or Sanitize?

17 Aug, 2009 - 02:36 PM
Post #5

require_once("brain.php"); //Fatal error :/
Group Icon

Joined: 10 May, 2009
Posts: 701



Thanked: 47 times
Dream Kudos: 75
Expert In: PHP, MySQL

My Contributions
Lol, wow, yeah...
That's what I meant XD

Working on stupid servers with magic quotes enabled leaves me thinking about stripslashes dry.gif

Yours,
Shane~
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/21/09 01:29PM

Live Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month