Error while accessing site with special characters. Update collation for database.
Solution :-
1. Create one collation file in the user account with the “.php” extension. Eg. collat.php
Note : Create the file in public_html or any recommended script path.
2. Write following code in the file :
<?php
$db = mysql_connect(‘hostname’,’database_user’,’database_password’);
if(!$db) echo “Cannot connect to the database – incorrect details”;
mysql_select_db(‘database_name’); $result=mysql_query(‘show tables’);
while($tables = mysql_fetch_array($result)) {
foreach ($tables as $key => $value) {
mysql_query(“ALTER TABLE $value COLLATE database_collation”);
}}
echo “The collation of your database has been successfully changed!”;
?>
Note : Replace the database name, username and password in the above code with the collation you wish to set.
> chmod 644 collat.php
> chown user.user collat.php
Once the file get run it will set collation for the database present in the collat.php file.