Re: MySQLi connection character set problem

From: Date: Wed, 12 Jan 2005 01:14:47 +0000
Subject: Re: MySQLi connection character set problem
References: 1 2  Groups: php.db 
Request: Send a blank email to php-db+get-38110@lists.php.net to get a copy of this message
Thanks, this is exactly what I needed. It seems I got tricked by what I expected the mysqli_character_set_name function to do. It seems this function only "returns the DEFAULT character set for the database connection" (quoted from manual) and not the actual character set defined. For example, if you run the code below: // bla bla bla $mysqli->options(MYSQLI_INIT_COMMAND, "SET NAMES 'UTF8'"); print mysqli_character_set_name(); it will still output (in my case) "latin1_swedish_ci" although the connection, at this stage, is set to UTF-8. If the mysqli developers are reading this, it could be useful to have a function to fetch the currently defined connection character set (mysqli_current_character_set_name perhaps ?). Thanks again. On 05-01-11, at 03:45, Unreal HSHH wrote:
I have to use this $mysqli = mysqli_init(); $mysqli->options(MYSQLI_INIT_COMMAND, "SET NAMES 'UTF8'"); $mysqli->real_connect($mysqli_addr, $mysqli_user, $mysqli_pass, $mysqli_db); if (mysqli_connect_errno()) { printf("Connect failed: %s\n", mysqli_connect_error()); exit(); }


« previous php.db (#38110) next »