0

My database and tables inside database collation is utf8_general_ci My connection php file is as follows :

$connection = mysqli_connect(DBHOST,DBUSER,DBPW,DBNAME);

if (!$connection) {
    die("Database connection failed: " . mysqli_error($connection));
}

// 2. Select a database to use 
$db_select = mysqli_select_db($connection, DBNAME);
mysqli_query($connection,"SET NAMES 'utf8'");
mysqli_query($connection,"SET CHARACTER SET utf8");
if (!$db_select) {
    die("Database selection failed: " . mysqli_error($connection));
}

I even add a header to my connection.php file as follows :

header('content-type:text/html; charset=utf-8'); 

Now when i try to insert Arabic characters into database i got this :

ع ج &#16

i also tried to do this :

mysqli_query($connection,"SET NAMES 'cp1256'");
mysqli_query($connection,"SET CHARACTER SET cp1256");

But i still get the same result stored in my database. Any idea please ??

wfareed
  • 139
  • 2
  • 17
  • 1
    Possible duplicate of [Save Data in Arabic in MySQL database](https://stackoverflow.com/questions/6859018/save-data-in-arabic-in-mysql-database) – Jaime Sep 16 '17 at 15:25
  • i searched and none of the existing answers helped my solve my issue – wfareed Sep 16 '17 at 15:26
  • Check this question/answer: https://stackoverflow.com/questions/31459458/insert-an-arabic-text-mysql – Berlin Sep 16 '17 at 16:58

1 Answers1

0
  1. Use this header('content-type:text/html; charset=utf-8');
  2. mysqli_query($connection,"SET CHARACTER SET utf8");
  3. MySQL connection collation: utf8_general_ci
  4. And save the file of your code in utf-8.

If you use note++

look at this image

enter image description here

Community
  • 1
  • 1