You are currently viewing How to solve the database error in Drupal

How to solve the database error in Drupal

Here is the code of resolving the error related to database table formate error may include

PDOException: SQLSTATE[HY000]: General error: 1267 Illegal mix of collations (utf8_unicode_ci,IMPLICIT) and (utf8_general_ci,IMPLICIT) …. … ..

 

< ?php
// your connection
mysql_connect("localhost","username","password");
mysql_select_db("databasename");

// convert code
$res = mysql_query("SHOW TABLES");
while ($row = mysql_fetch_array($res))
{
foreach ($row as $key => $table)
{
mysql_query("ALTER TABLE " . $table . " CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci");
echo $key . " => " . $table . " CONVERTED
";
}
}
?>