I am trying to insert special character (entities) into mysql db using php.
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "test";
$autoid = $_REQUEST["autoid"];
// $explanation = htmlspecialchars($_REQUEST["explanation"]);
$explanation = mysql_real_escape_string("<p>hello how are you Ê</p>");
echo $explanation;
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
//$explanation = utf8_decode(trim(mysql_real_escape_string($explanation));
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "UPDATE question_master SET explanation='$explanation' WHERE autoid=$autoid";
if ($conn->query($sql) === TRUE) {
echo "Record updated successfully";
} else {
echo "Error updating record: " . $conn->error;
}
$conn->close();
?>
the string I try to pass is <p>hello how are you Ê</p>
but after updating in mysqldb it becomes <p>hello how are you Ê</p>
. I am new to mysql, no idea what going wrong.
Table collation is utf8mb4_bin table collation is utf8_bin