This is the blog to share your views and ideas and opinions of diffrent type of people, on our politics, media movies on each and every thing....

don't forget to comment.....!

diff between mysql_escape_string and mysql_real_escape_string

$item = "Zak's Laptop";
$a=mysql_connect('localhost','root','');
//$escaped_item = mysql_escape_string($item);
$escaped_item = mysql_real_escape_string($item);
echo $escaped_item;

?>
output :  Zak\'s Laptop
See the code above we use the server connection, in case of using the mysql_real_escape_string,
if you are not mention the server connection
i.e $a=mysql_connect('localhost','root','');
you may get the error below
Warning: mysql_real_escape_string(): Access denied for user 'ODBC'@'localhost' (using password: NO) in c:\program files\easyphp1-8\www\currentworking\bikes_adda\mysql.php on line 5

Warning: mysql_real_escape_string(): A link to the server could not be established in c:\program files\easyphp1-8\www\currentworking\bikes_adda\mysql.php on line 5

so before using  mysql_real_escape_string , use server connection.
BUT In case of mysql_escape_string , we noneed to use of server conncetion.
 just use the code normally...

$item = "Zak's Laptop";
$escaped_item = mysql_escape_string($item);
echo $escaped_item;
?>
output :  Zak\'s Laptop

Note: mysql_escape_string() does not escape % and _

0 comments:

Post a Comment

 
Bookmark and Share blogarama.com