What is the use of mysql_real_escape_string() function?

What is the use of mysql_real_escape_string() function?

Team Leader Asked on October 12, 2017 in PHP.
Add Comment
1 Answer(s)

mysql_real_escape_string()  Escapes special characters in a string for use in an SQL statement otherwise an error like E_WARNING is generated.

Sample example


<?php
//MySQL connection
includes("config.php");
$username= "bikash's";
$uname= mysql_real_escape_string($username);

$query = "SELECT * FROM user_master WHERE user_name = '$uname'";

var_dump($uname);
var_dump($query);
?>

Team Leader Answered on December 4, 2017.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.