co.ador Posted December 16, 2009 Share Posted December 16, 2009 This is the error Setting database encoding failed:Can't initialize character set utf-8 (path: C:\mysql\\share\charsets\) How can I change the charset so it can be compatible? <?php $connection = mysql_connect(DB_SERVER,DB_USER,DB_PASS); if(!$connection){ die("Database connection failed:" . mysql_error()); } //mysql_set_charset('utf8',$connection); if (!mysql_set_charset('utf-8', $connection)) { die('Setting database encoding failed:' . mysql_error()); } $db_select = mysql_select_db(DB_NAME, $connection); if(!$db_select){ die("Database selection failed: " . mysql_error()); }?> The code above is the connection to the database and i have set it to die if there is not mysql_set_charset to utf8: <?php if (!mysql_set_charset('utf-8', $connection)) { die('Setting database encoding failed:' . mysql_error()); }?> How can I set to utf8? what I can see is that in the folders share the charcterset utf8.xml is not in there. that means I will have to download it and put it in there? thank you Link to comment https://forums.phpfreaks.com/topic/185386-i-am-getting-an-database-charset-error/ Share on other sites More sharing options...
premiso Posted December 16, 2009 Share Posted December 16, 2009 I am not sure, but I think you need to select the database first. Switch around the select_db and the charset and see if that works. Link to comment https://forums.phpfreaks.com/topic/185386-i-am-getting-an-database-charset-error/#findComment-978684 Share on other sites More sharing options...
co.ador Posted December 16, 2009 Author Share Posted December 16, 2009 I have switch around the select_db and the charset like this <?php $connection = mysql_connect(DB_SERVER,DB_USER,DB_PASS); if(!$connection){ die("Database connection failed:" . mysql_error()); } //mysql_set_charset('utf8',$connection); $db_select = mysql_select_db(DB_NAME, $connection); if(!$db_select){ die("Database selection failed: " . mysql_error()); } if (!mysql_set_charset('utf-8', $connection)) { die('Setting database encoding failed:' . mysql_error()); } ?> but stil threw the same error... Setting database encoding failed:Can't initialize character set utf-8 (path: C:\mysql\\share\charsets\) Link to comment https://forums.phpfreaks.com/topic/185386-i-am-getting-an-database-charset-error/#findComment-978689 Share on other sites More sharing options...
premiso Posted December 16, 2009 Share Posted December 16, 2009 It seems to possibly something with how your MySQL is setup as: C:\mysql\\share\charsets\ is not a valid path (Unless you can type that in Windows Explorer and browse to it). I would look into your MySQL setup and possibly do a re-install of MySQL. Link to comment https://forums.phpfreaks.com/topic/185386-i-am-getting-an-database-charset-error/#findComment-978690 Share on other sites More sharing options...
co.ador Posted December 16, 2009 Author Share Posted December 16, 2009 I am using wamp which has a package of three, Is it possible to only delete mysql server and leave php and apache? Link to comment https://forums.phpfreaks.com/topic/185386-i-am-getting-an-database-charset-error/#findComment-978697 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.