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 Quote Link to comment 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? Quote Link to comment 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 Quote Link to comment 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. Quote Link to comment 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. Quote Link to comment 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. Quote Link to comment 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.