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 8165305
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T19:30:18+00:00 2026-06-06T19:30:18+00:00

I have been struggling with encoding problems in MySQL for a while. I am

  • 0

I have been struggling with encoding problems in MySQL for a while. I am building a database that will contain not only Latin but Cyrillic and Arabic text as well. So here is an example on how I create the database:

CREATE DATABASE db1
DEFAULT CHARACTER SET utf8   
COLLATE utf8_unicode_ci;

Then a table:

CREATE TABLE TempTb1
(
ID INT PRIMARY KEY,
name VARCHAR(100) NOT NULL,
arabic VARCHAR(100) NOT NULL
)
DEFAULT CHARACTER SET utf8   
COLLATE utf8_unicode_ci;

And when I put some data and select it I get only some strange characters. So I wrote a small PHP script to test it but it doesn’t work either:

<?php
header('Content-type: text/plain; charset=utf-8');

$a = mysql_connect('localhost','root','') or die('Problem connecting to database!');
$b = mysql_select_db('db1') or die('Problem selecting database');
mysql_set_charset('utf8');
mysql_query("set names 'utf8'");
mysql_query('set character set utf8');

$query = mysql_query("SELECT * FROM Tb1;");

while($row = mysql_fetch_assoc($query))
    {   
        $id = $row['ID'];
        $name = $row['name'];
        $arabic = $row['arabic'];

        echo $id.' '.$name.' '.$arabic.PHP_EOL;
    }
?>

I have tested with both utf8_unicode_ci and utf8_general_ci. What could be wrong? BTW I have EasyPHP 5.2.10.

  • 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-06T19:30:20+00:00Added an answer on June 6, 2026 at 7:30 pm

    Whatever happens to your characters, happens before they reach to MySQL, I guess. Characters are converted to numbers by the computer when we enter the characters. Then these numbers travel from here to there, between web forms and servers, web servers and scripting interpreters, then database servers and back to web pages following the same way.

    Where and how you enter your data? Data should exit the way it entered. If your data is provided via web forms, check your web page encodings and how you submit forms. How you get them in your PHP scripts and how you send them to database server. The guilty part here is probably not MySQL but another place. It can be MySQL too; but it is not the only place of possible misbehavior and it probably is not.

    Check your pages, check headers as they arrive to your browser.

    About comments your question received, no it is not good to use ISO5 because you need multiple of ISO5 families. You must go with a Unicode encoding, for most of the time, the best being utf-8. Also, this is not about which MySQL library you use unless that library has some known bugs which is very unlikely for something that old. 🙂 You should still use whatever recommended as best practices; but your current problem is not related to the library you use. The evil is at the difference between how you enter your data and how you view it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been struggling with this for a while now. given a set of
I have been struggling with a unit testing problem on Android for a while
I have been struggling with this for a while and could really use some
I have been struggling with the best way to make sure that the certain
I have been struggling with a small problem for a while. It's been there
I have been struggling with a program that calls functions which return strings. I
I have been struggling with this for a while now so I thought I
I have been struggling with Subversion for some time, thinking it was beginners problems
I have been struggling with a problem that at first glance might look easy
I have been struggling with this thing for a while so I finally decided

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.