0

I Want To Read Persian Characters From MySQL With PHP.Characters Are Well Stored By PHP In MySQL. But When Reading Them The Characters Are In The Form Of "?".

This Is My Data In MySQL:

My SQL Picture

This Is My Code For Select Data:

$Query = "SELECT ID,Json FROM su";
$MySQLAddress = "___";
$MySQLUsername = "___";
$MySQLPassword = "___";
$MySQLDataBaseName = "___";
$MySQLConnection = mysqli_connect($MySQLAddress,$MySQLUsername,$MySQLPassword,$MySQLDataBaseName);
if ($MySQLConnection -> connect_errno) {
      echo "Failed to connect to MySQL: " . $MySQLConnection -> connect_error;
      exit();
}
$MySQLConnection->query("SET NAMES 'utf8'");
$MySQLConnection->query("SET CHARACTER SET 'utf8'");
$MySQLConnection->query("SET character_set_connection = 'utf8'");
$Result = $MySQLConnection->query($Query);

But This Is My Result: Data Table Picture

Dharman
  • 30,962
  • 25
  • 85
  • 135
  • Remove all these SET lines and add `$mysqli->set_charset('utf8mb4');` just like is shown in the manual https://www.php.net/manual/en/mysqli.construct.php – Dharman Jan 27 '21 at 14:34
  • What encoding do you use to display the characters? It might be that you receive the characters correctly, but display them using incorrect format – Abbas Akhundov Jan 27 '21 at 14:35
  • I encoded the characters with utf8. Unfortunately your code does not work! – Mahdi Khezrabadi Jan 27 '21 at 14:51
  • See "question mark" in https://stackoverflow.com/questions/38363566/trouble-with-utf8-characters-what-i-see-is-not-what-i-stored – Rick James Jan 30 '21 at 00:49

0 Answers0