Jump to content

[SOLVED] What's better?


dustinnoe

Recommended Posts

addslashes() VS. mysql_real_escape_string()

 

mysql_real_escape_string() does more in the way of escaping special characters but runs about three times slower than addslashes()

 

I timed script execution and these are my results(in microseconds):

mysql_real_escape_string(): 7.3E-005

addslashes(): 2.4E-005

 

What's better?

 

Should I go for the speed of addslashes() or the completeness of mysql_real_escape_string()?

Link to comment
https://forums.phpfreaks.com/topic/44321-solved-whats-better/
Share on other sites

What is funny is that I had never even heard about mysql_real_escape_string() until browsing the manual.  Every tutorial I have ever read has used addslashes(). 

 

As far as I can tell though addslashes() will do enough to stop SQL injection.  Can you think of any examples where mysql_real_escape_string() is nessesary over addslashes()?

Link to comment
https://forums.phpfreaks.com/topic/44321-solved-whats-better/#findComment-215254
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.