suttercain Posted July 27, 2007 Share Posted July 27, 2007 Hi Everyone, I am doing a project and some of the database information is being displayed in the borwser as a tilted box with a question mark inside. Does anyone know what I should set my charset to be to avoid this? The website will be for us residents. Thanks SC Link to comment https://forums.phpfreaks.com/topic/62050-mysql-charset-issue/ Share on other sites More sharing options...
effigy Posted July 27, 2007 Share Posted July 27, 2007 Log into MySQL and type the command \s, this will give you the status information and the character set configurations: Server characterset: latin1 Db characterset: latin1 Client characterset: latin1 Conn. characterset: latin1 What do you have for these? What version of MySQL? What character set is your program using, either in your headers, or meta tag? Link to comment https://forums.phpfreaks.com/topic/62050-mysql-charset-issue/#findComment-308938 Share on other sites More sharing options...
suttercain Posted July 27, 2007 Author Share Posted July 27, 2007 Hi Effigy Meta Doc <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> Collation latin1_swedish_ci MySQL charset: UTF-8 Unicode (utf8) MySQL connection collation: UTF-8 Unicode_ci MySQL 5 Thanks Link to comment https://forums.phpfreaks.com/topic/62050-mysql-charset-issue/#findComment-308945 Share on other sites More sharing options...
effigy Posted July 27, 2007 Share Posted July 27, 2007 The data coming from MySQL will be UTF-8. Changing charset in your meta tag to "utf-8" should fix the issue. Link to comment https://forums.phpfreaks.com/topic/62050-mysql-charset-issue/#findComment-308950 Share on other sites More sharing options...
kiss-o-matic Posted July 27, 2007 Share Posted July 27, 2007 The data coming from MySQL will be UTF-8. Changing charset in your meta tag to "utf-8" should fix the issue. In versions 4.1 (I think, definitely 4.2) and up you have to do the following. When you connect to your database, you have to tell it what charset you want. Otherwise, you will get garbage. $db = mysql_connect('localhost','user','pass' ) or die ( Could not connect: ' . mysql_error() ); mysql_select_db( 'dbname' ) or die; if ( !mysql_query("SET CHARACTER SET utf8", $db ) ) { echo "problem setting character<br>"; } if ( !mysql_query("SET NAMES 'utf8'", $db ) ) { echo "problem setting name<Br>"; } Noticy in effigy's post there's a client portion. You need to have this set (check you my.cnf) for it to work right, AFAIK, and the charset in the above queries need to match the client collation & charset. FYI, if you're going to deal w/ multibyte characers, leave it in Unicode. You will kill yourself messing w/ the others. Link to comment https://forums.phpfreaks.com/topic/62050-mysql-charset-issue/#findComment-309022 Share on other sites More sharing options...
suttercain Posted July 28, 2007 Author Share Posted July 28, 2007 I tried both suggestions, but I am still having the same issue. Any other advice? Thanks. Link to comment https://forums.phpfreaks.com/topic/62050-mysql-charset-issue/#findComment-309279 Share on other sites More sharing options...
kiss-o-matic Posted July 28, 2007 Share Posted July 28, 2007 Did you set the client character set in MySQL? Should look like this is your my.cnf [client] default-character-set=utf8 Link to comment https://forums.phpfreaks.com/topic/62050-mysql-charset-issue/#findComment-309326 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.