$HotelName = "Adams’ Inn";
$ID = 1;
$stmt = $sql->prepare("UPDATE coupons SET HotelName=? WHERE ID=?");
$stmt->bind_param("si",$HotelName,$ID);
$stmt->execute();
Output: Adams’ Inn
By the way, I have the following:
char set: utf8
collation: utf8_general_ci
checklist
$sql->set_charset('utf8')
right after connect.header('Content-Type: text/html; charset=utf-8');
before any outputThere are 2 sides involved - server and client. Client means PHP script, not HTTP client. And server needs to know what encoding does client expect.
And you set only server side encoding, telling mysql in which encoding data have to be stored.
But there is also a client.
In fact, Mysql is great in recoding. As long as one encoding can be translated into other, Mysql can do it. For the different clients for example.
It is not too much demanded nowadays, but this feature exists. So, Mysql need to know which encoding is supported by client. For this very purpose set_charset()
function exists.
You are missing SET
keyword in your query
$HotelName = "Adams’ Inn";
$ID = 1;
$stmt = $sql->prepare("UPDATE coupons SET HotelName=? WHERE ID=?");
$stmt->bind_param("si",$HotelName,$ID);
if($result=$stmt->execute())
echo "Data Updated Sucessfully!!!";
else
echo "Error in Update";
Its so simple
Just put
mysqli_set_charset($db_connection, 'utf8');
after your database connection.
Example
$con=mysqli_connect("localhost", "root", "xxxxx","database");
mysqli_set_charset($con, 'utf8');