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
10902
September 05, 2011 04:23PM
2786
September 07, 2011 08:01PM
4185
September 08, 2011 04:45PM
2435
September 09, 2011 06:46PM
3982
September 11, 2011 08:03AM
2222
September 12, 2011 11:30AM
2884
September 12, 2011 06:16PM
2047
September 12, 2011 06:17PM
2091
September 13, 2011 09:44PM
2437
September 17, 2011 05:53AM
2137
September 18, 2011 01:45PM
2175
September 19, 2011 04:10PM
2155
September 20, 2011 08:19PM
2454
September 25, 2011 12:09PM
2189
September 28, 2011 09:53PM
2213
September 29, 2011 02:44PM
2795
September 30, 2011 10:14AM
2801
September 10, 2011 03:07PM
2774
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.