1

I try to show query in Hebrew from mysql mariadb 10.2 through php. The problem is that all I see is question marks as the picture below:

https://i.stack.imgur.com/SZGJJ.jpg

I changed all the database, tables and columns to UTF8_general_ci. I updated the meta tag, as u can see in the code below, the header, and when I put mysql_query("SET NAMES 'utf8'") it says https error 500, so I made it a comment.

config_php:

<?php
session_start();
$host = "localhost";
$user = "users";
$password = "123";
$dbname = "users";
$con = mysqli_connect($host, $user, $password,$dbname);
if (!$con) {
die("Connection failed: " . mysqli_connect_error());
//mysql_query("SET NAMES 'utf8'");
mysqli_set_charset('utf8',$con);
}

status.php:

I couldn't post the code for some reason so heres a picture:

https://i.stack.imgur.com/F8tAy.jpg

So I thought it would give me no question marks, but it did.

halfer
  • 19,824
  • 17
  • 99
  • 186
Idan
  • 135
  • 1
  • 7
  • i bet the problem is the rendering charset. what happens if you add `header("Content-Type: text/html;charset=utf-8");` to the top of the script? – hanshenrik Aug 27 '19 at 18:36
  • You've said that you've changed all db, tables and columns to UTF8_general_ci. Were the data already in them when they were not UTF8? If that's the case then data in your DB are already corrupted and you won't be able to retrieve them correctly.You would need to fix the data in DB first. – Michal Hynčica Aug 27 '19 at 18:48
  • Yea I did both what you two said, and it still doesnt work.. you can even see in the pictures I uploaded the code you just wrote – Idan Aug 27 '19 at 20:40

2 Answers2

0
mysqli_set_charset('utf8',$con);

-->

mysqli_set_charset($con, 'utf8');

Even better is to get in the habit of using the OO coding style:

$con->mysqli_set_charset('utf8');

If you have further problems, see "quotation mark" in Trouble with UTF-8 characters; what I see is not what I stored

Do not use any of the mysql_* functions; they are deprecated and do not work with the mysqli_* functions.

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

I did manage to solve it, by changing all the database column and tables to utf8mb4_unicode_520_ci and adding mysqli_query($con,"SET NAMES 'utf8mb4'"); and adding to the form.. hope it helps to somone who has the same problem!

Idan
  • 135
  • 1
  • 7