0

I have created a mysql database conected to an android app through php, this is my configuration file:

<?php
$username="aaaaa";
$password="bbbbb!";
$host="localhost";
$database="dbname";
$mysqli = new mysqli("localhost", $username, $password, $database);
$mysqli->set_charset("utf8mb4");
$con = mysqli_connect($host,$username,$password, $database) or die(mysqli_error($con));
?>

What is the addition or modification to support the Arabic language, as the Arabic writing appears as question marks. Note: The encoding of the database, tables and fields is utf8_general_ci.

  • 4
    Does this answer your question? [UTF-8 all the way through](https://stackoverflow.com/questions/279170/utf-8-all-the-way-through) – Rain Aug 12 '21 at 08:54
  • How can I add this line to my code : $dbh = new PDO('mysql:charset=utf8mb4'); – Abu Elhaytham Aug 12 '21 at 09:04
  • You are using `mysqli` not `PDO`. Please complete reading the answer in the link it covers `mysqli` too. – Rain Aug 12 '21 at 09:06
  • Since you're using mysqli, you can't use a PDO-specific line of code. Look again at the answer for the mysqli version of that setting. – ADyson Aug 12 '21 at 09:06
  • I added these two lines and the problem is still there: $mysqli = new mysqli("localhost", $username, $password, $database); $mysqli->set_charset("utf8mb4"); – Abu Elhaytham Aug 13 '21 at 07:36
  • in database server I found: server charset: cp1252 West European (latin1). is it the problem? – Abu Elhaytham Aug 13 '21 at 08:07
  • Yes, cahnge `cp1252` to `utf8mb4` in your database server too. – Rain Aug 13 '21 at 10:21
  • Can I change it or is that the responsibility of the hosting company manager? – Abu Elhaytham Aug 13 '21 at 12:06

1 Answers1

0

utf8mb4 handles all the Arabic characters.

Something is set up incorrectly for you to get "?". See utf8 trouble shooter and search for "question mark".

Rick James
  • 135,179
  • 13
  • 127
  • 222