I want to insert Arabic characters to database using pdo with php, but I got these characters in database
الجامع ا
and when I use
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
the result was
??????????
I make the collection of the columns in phpMyadmin
utf8mb4_unicode_ci
and this
utf_unicode_ci
but I still have the same error.
And I tried to make the connection like this: (totti,totti is not my really username and password)
parent::__construct('mysql:host=localhost;dbname=ams-competation;charset=utf8"', 'totti', 'totti');
but still I get the same error
And I also tried like this:
parent::__construct('mysql:host=localhost;dbname=ams-competation;charset=utf8', 'totti', 'totti'
,array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"));
and doesn’t work 🙁
and after submitting the form and before inserting to database i echo the values and i got arabic characters , that means my problems is in database , but echo works just without using meta
and when i tried to insert arabic characters from phpmyadmin IT WORKS
i am using
phpmyadmin in XAMPP 1.7.4
php 5.5.3
finally i found the solution and it is:
- make the collection of the columns utf8_unicode_ci
- put
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">in the header
Try setting the connection to utf-8 when making connection to the database.
Set the constants first in your config file like this:
Then set your connection like this:
Set your connection like this: