- MySQL Improved (mysqli) PHP extension
- PDO (PHP Data Objects)
This article assumes that you already know how to connect to a MySQL database using PHP. For information about how to do this, please see this article.
Determining which character sets are available on a server
To determine which character sets are available on your server for MySQL, log in to your account using SSH, and then type the following command:Setting the character set using the MySQL Improved extension
If you are using the MySQL Improved (mysqli) extension, use the set_charset method to specify the character set. For example, the following sample code demonstrates how to specify the Windows Arabic character set using mysqli:Setting the character set using PDO (PHP Data Objects)
To specify the character set using PDO, all you have to do is include the charset setting in the connection string. For example, the following sample code demonstrates how to specify the UTF-8 Unicode character set using PDO:More information
- To view the official online documentation for the MySQL Improved extension, please visit http://www.php.net/manual/en/book.mysqli.php.
- To view the official online documentation for PDO, please visit http://www.php.net/manual/en/book.pdo.php.