mysql_escape_string & mysql_real_escape_string

mysql_escape_string & mysql_real_escape_string

mysql_escape_string
==============

mysql_escape_string

-  It escapes a string for use in a mysql_query. This function will escape the unescaped_string, so that it is safe to place it in a

mysql_query(). It is similar to addslashes() function It does not escape % and _.

Syntax:
=====
string mysql_escape_string ( string unescaped_string)

Example:
=======

$str = "your's";
echo $str = mysql_escape_string($str);

The Output is
your\'s

===========================
======================================
====================================

mysql_real_escape_string
==================

mysql_real_escape_string

- It  escapes special characters in a string for use in a SQL statement, taking into account the current charset of the connection.
This function will escape special characters in the unescaped_string, taking into account the current charset of the connection so that it is safe to place it in a

mysql_query(). It is similar to mysql_escape_string.

Syntax:
=====
string mysql_real_escape_string ( string unescaped_string [, resource link_identifier])

====================================
=====================================
===============================

Leave a Reply

You must be logged in to post a comment.


All material @ copyrighted by chrisranjana.com. If you want to link to this article you are welcome to do so. Unauthorized publication is strictly prohibited. This developer tutorial website contains articles by Php programmers , Software developers, Mysql programmers and asp c# programmers. This website also contains ajax tutorials and advanced mysql sql stored procedures and functions tutorials and sample codes.