I would like to establish a connection to my MYSQL database. Unfortunately, I haven’t found the right one for me anywhere. Does anyone have a solution that is similar to this one?
I have tried this but i want to have utf 8 to charset and it does not work
`
` <?php
$servername = "localhost";
$username = "u123456789_User";
$password = "MyStr0ngPa$!";
$conn = mysqli_connect($servername, $username, $password);
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
echo "Connected successfully";
mysqli_close($conn);
?>
`
`
2
Answers
try it with:
To use UTF-8, set the client character set using mysqli_set_charset once the connection has been established.
The
utf8mb4
uses UTF-8 encoding using one to four bytes per character.