1

I run a fantasy football management game and I'm in the process of adding multiple nationalities.

How can I set up PHP / MySQL to accept foreign characters (ALL TYPES). At the moment I'm trying to add Arabic but I'm not having much luck. Which encoding do I need to use and how do I make it work?

I've set both to UTF-8 unicode Please see here: http://www.footielegend.com/test/header.php

It stores it fine in the database.

DugoutSoccer
  • 422
  • 5
  • 19
  • 1
    Using UTF-8 all the way through - on the page, in the data base, in the database connection - is the required first step. Are you doing that? (The second step for Arabic is dealing with Right-To-Left script, which I don't have much experience with, but all the necessary information should be available on Stack Overflow already.) – Pekka Nov 22 '11 at 23:41

2 Answers2

1

Figured it, I just needed to add this after I connect to the database:

mysql_query("SET character_set_results = 'utf8', character_set_client = 'utf8', character_set_connection = 'utf8', character_set_database = 'utf8', character_set_server = 'utf8'");
DugoutSoccer
  • 422
  • 5
  • 19
  • Maybe this assist you: http://stackoverflow.com/questions/845418/hsqldb-table-encoding/8656950#8656950 http://stackoverflow.com/questions/7501924/php-messing-with-html-charset-encoding/7502564#7502564 But as Pekka I't know much about Arabic, Chinese and Russian characters. – Diblo Dk Dec 28 '11 at 14:19
0

Use UTF-8. Make sure your database collation is set to that (db, tables, and columns) and your php script also.

Alexey Gerasimov
  • 2,131
  • 13
  • 17