Link to home
Start Free TrialLog in
Avatar of rgb192
rgb192Flag for United States of America

asked on

sql version of mysql_real_escape_string()

mysql_real_escape_string()

how is this used in sql server 2005
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

I'm not sure there is a perfect analog.

http://blog.sqlauthority.com/2008/02/17/sql-server-how-to-escape-single-quotes-fix-error-105-unclosed-quotation-mark-after-the-character-string/

mysql_real_escape_string() is smarter than addslashes().

Do you have a code sample that shows the problem you're having with escapes in SQL 2005?
Avatar of rgb192

ASKER

this is for mysql

and i would like it for sql server
$fn  = mysql_real_escape_string($_POST["firstname"]); 
$ln  = mysql_real_escape_string($_POST["lastname"]);

Open in new window

Avatar of Aneesh
isn't that a Php function ? I am not sure how it relates to SQL Server
@aneeshattingal: Maybe he is using ODBC?
Agree with Ray, I don't know of a direct function call that duplicates the abilities of mysql_real_escape_string.  You would have to construct your own on the PHP side or in a user defined function on MS SQL side.

See if this helps for that purpose.
http:Q_21927070.html
Avatar of rgb192

ASKER

yes using using ODBC

php to connect to sql server 2005
ASKER CERTIFIED SOLUTION
Avatar of Bill Prew
Bill Prew

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rgb192

ASKER

I saw the other experts exchange link

and the answer is

for mssql-server str_replace("'", "''", $data) is typical sufficient to escape the data so no sqlinjection is possible.


how would this apply to
$fn  = mysql_real_escape_string($_POST["firstname"]);  
$ln  = mysql_real_escape_string($_POST["lastname"]);

Open in new window

SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rgb192

ASKER

thanks