note 61550 added to function.mysqli-set-charset

From: Date: Mon, 06 Feb 2006 16:31:09 +0000
Subject: note 61550 added to function.mysqli-set-charset
Groups: php.notes 
Request: Send a blank email to php-notes+get-103133@lists.php.net to get a copy of this message
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. ---- Server IP: 61.195.146.164 Probable Submitter: 218.219.202.171 ---- Manual Page -- http://www.php.net/manual/en/function.mysqli-set-charset.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+61550 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+61550&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+61550&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+61550&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+61550&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+61550&report=yes&reason=non-english Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+61550&report=yes&reason=already+in+docs Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+61550&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+61550&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#103133) next »