Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8849373
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T12:38:04+00:00 2026-06-14T12:38:04+00:00

I want to insert Arabic characters to database using pdo with php, but I

  • 0

I want to insert Arabic characters to database using pdo with php, but I got these characters in database

الجامع &#1575

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:

  1. make the collection of the columns utf8_unicode_ci
  2. put <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> in the header
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T12:38:05+00:00Added an answer on June 14, 2026 at 12:38 pm

    Try setting the connection to utf-8 when making connection to the database.

    • If you’re following rules and best practices:

    Set the constants first in your config file like this:

    define('DB_SERVER', 'your_hostname');
    define('DB_USERNAME', 'your_username');
    define('DB_PASSWORD', 'your_password');
    define('DB_CHARSET', 'UTF-8');
    define('DB_DATABASE', 'your_dbname');
    define('PDO_DSN', 'mysql:host=' . DB_SERVER . ';dbname=' . DB_DATABASE . ';charset=' . DB_CHARSET);
    

    Then set your connection like this:

    $_dbhandler = new PDO(PDO_DSN, DB_USERNAME, DB_PASSWORD,array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES UTF8"));
    
    • Quick and dirty

    Set your connection like this:

    $dbhandler = new PDO('mysql:host=your_hostname;dbname=your_dbname;charset=UTF-8', $user, $pass);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to insert a data in my SQL Server database using jQuery Dialog
I want to insert 10,00,000 rows into the database, but the it takes too
I want insert following checkbox in a row from database table, but have error,
I want to insert some value from first and second foreach into database, but
I want to insert arabic content from asp.net page to mysql5.5,I am using mysqlconnector5.2.7
I want to insert a record into a MySQL database table from a formulaire.
I want to insert a date record to an Access database. Here is my
I want to insert the following include tag into my webpage using JavaScript. <!--#include
I want to insert data from wavemaker into database which will be inserted by
I have a problem, I want insert data with a button click method, but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.