note 61550 deleted from function.mysqli-set-charset by bjori

From: Date: Sun, 26 Mar 2006 12:27:24 +0000
Subject: note 61550 deleted from function.mysqli-set-charset by bjori
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-106629@lists.php.net to get a copy of this message
Note Submitter: feeling_zen ---- If anyone knows of a way to set the encoding of the mysqli extension permanently without using mysqli_set_charset() it would be welcome. Preferably in the php.ini file. However, for those experiencing collation mismatch errors back from MySQL such as: "Illegal mix of collations (utf8_general_ci,IMPLICIT) and (latin1_swedish_ci,COERCIBLE) for operation '='" You can set the encoding of variables beforehand in the actual query. So even if you have a LATIN1 connection to a server that is UTF8 you can get an error-free response. EXAMPLE (LATIN1 mysqli client talking to UTF8 MySQL server) $query="SELECT * FROM table1 WHERE user='{UTF8 STRING}'" // generates an error. but $query="SELECT * FROM table1 WHERE user=_utf8'{UTF8 STRING}'" // works okay OR If you have many queries to issue set the client encoding for the entire session using the SQL statement: $query="SET character_set_client=utf8"; // causes your client to behave as though you called mysqli_set_charset(). You won't need to declare encoding or collation before each string variable in your SQL statements.

« previous php.notes (#106629) next »