Just wanted to test mysqli_real_escape_string. I was expecting the script embedded in $string to not work. However I can see the alert message.
<?php
$servername = "localhost";
$username = "root";
$password = "";
$database = "test_db";
// Create connection
$conn = new mysqli($servername, $username, $password, $database);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$string = "<script>alert('This is script from php')</script>";
echo mysqli_real_escape_string($conn,$string);
?>
As far as I know that mysqli_real_escape_string should stop the script from execution. Is there a better way. I know about the prepared statements .. anything apart from that I shoud do?
** NOT SIMILIAR AS This one **