MySQL Forums
Forum List  »  Full-Text Search

Arabic text in mysql Varchar row
Posted by: Mark Webley
Date: September 05, 2011 04:23PM

Hello

Does anyone out there have any idea of how to solve the following:

I am inserting a 'title' and 'description' into mysql with the same single query for a tabled named 'user'. But the cell named 'title' set as varchar(255) always comes out wrong.

I HAVE A TABLE ROW named 'description' as longtext
that WORKS perfectly FOR ARABIC TEXT (and I can see the Arabic text clearly in the database for this row)

BUT the other cell named 'title' in the same row VARCHAR(255) does not work....

For example for a cell named title with VARCHAR(255),
the Arabic text always comes out as ???????????? when I insert the data via php.

When I cut and past Arabic text straight into the database cell named 'title' using navicat...I see the Arabic text perfectly.

Just before the insert into mysql, I echo the query to the browser and the Arabic text looks perfect.

But it is still inserting garbage '????????????' into the database, but only for the cell named 'title'...for Arabic text.

On db connect I have:
self::$conn = new MySQLI(localhost, username, password, databasename);

// to help with arabic characters
self::$conn->query("SET CHARACTER SET 'utf8'");
self::$conn->query("SET NAMES utf8");

To test I did the msyql query below:
SHOW VARIABLES LIKE '%version%';
HOW VARIABLES LIKE '%version%';

and the results are:
+--------------------------+------------------------------+
| Variable_name | Value |
+--------------------------+------------------------------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | utf8 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | latin1 |
| character_set_system | utf8 |
| character_sets_dir | \xampp\mysql\share\charsets\ |
| collation_connection | utf8_general_ci |
| collation_database | utf8_general_ci |
| collation_server | latin1_swedish_ci |
| completion_type | 0 |
| concurrent_insert | 1 |
| connect_timeout | 10 |
+--------------------------+------------------------------+
14 rows in set

+-------------------------+---------------------+
| Variable_name | Value |
+-------------------------+---------------------+
| protocol_version | 10 |
| version | 5.1.41 |
| version_comment | Source distribution |
| version_compile_machine | ia32 |
| version_compile_os | Win32 |
+-------------------------+---------------------+

the details of the table is described below after the below query:
describe user;

+------------------+--------------+------+-----+---------+-----------------------------+
| Field | Type | Null | Key | Default | Extra |
+------------------+--------------+------+-----+---------+-----------------------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| company | varchar(255) | YES | | NULL | |
| title | varchar(255) | YES | | NULL | ||
| description | longtext | YES | | NULL | |
+------------------+--------------+------+-----+---------+-----------------------------+


I am using XAMP on windows. PHP 5 and mysql version:

SHOW VARIABLES LIKE '%version%';
+-------------------------+---------------------+
| Variable_name | Value |
+-------------------------+---------------------+
| protocol_version | 10 |
| version | 5.1.41 |
| version_comment | Source distribution |
| version_compile_machine | ia32 |
| version_compile_os | Win32 |
+-------------------------+---------------------+


I spent more then 10 hours trying and testing and did PHP code tests with utf8_encoding() and utf8_decoding()...and only the Arabic text for 'title' is comes wrong...in my brower and also in the database, does anyone have any ideas...?

Thank you in advance... ?


Mark W
In Barcelona
www.adobeconsultant.co.uk

Options: ReplyQuote


Subject
Views
Written By
Posted
Arabic text in mysql Varchar row
11149
September 05, 2011 04:23PM
2865
September 07, 2011 08:01PM
4273
September 08, 2011 04:45PM
2481
September 09, 2011 06:46PM
4032
September 11, 2011 08:03AM
2263
September 12, 2011 11:30AM
2923
September 12, 2011 06:16PM
2092
September 12, 2011 06:17PM
2184
September 13, 2011 09:44PM
2488
September 17, 2011 05:53AM
2175
September 18, 2011 01:45PM
2214
September 19, 2011 04:10PM
2196
September 20, 2011 08:19PM
2520
September 25, 2011 12:09PM
2245
September 28, 2011 09:53PM
2282
September 29, 2011 02:44PM
2868
September 30, 2011 10:14AM
2866
September 10, 2011 03:07PM
2827
September 11, 2011 08:01AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.