note 90014 modified in function.mysql-set-charset by danbrown

From: Date: Wed, 01 Apr 2009 22:31:34 +0000
Subject: note 90014 modified in function.mysql-set-charset by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-152729@lists.php.net to get a copy of this message
Be careful when working with multiple databases via the same user/host that you specify "true" as the fourth argument to mysql_connect(), otherwise when you call this function it will set both db connections to the same character set. If you don't pass in "true" to mysql_connect() in the example below, $link1 and $link2 will have the same resource id# and both database connections will end up being set to utf-8 charsets. <?php $link1 = mysql_connect('localhost','user1','pass1',TRUE); $link2 = mysql_connect('localhost','user1','pass1',TRUE); mysql_selectdb('db1',$link1); mysql_selectdb('db2',$link2); mysql_set_charset('latin1',$link1); mysql_set_charset('utf8',$link2); ?> --was-- Be careful when working with multiple databases via the same user/host that you specify "true" as the fourth argument to mysql_connect(), otherwise when you call this function it will set both db connections to the same character set. If you don't pass in "true" to mysql_connect() in the example below, $link1 and $link2 will have the same resource id# and both database connections will end up being set to utf-8 charsets. $link1 = mysql_connect('localhost','user1','pass1',TRUE); $link2 = mysql_connect('localhost','user1','pass1',TRUE); mysql_selectdb('db1',$link1); mysql_selectdb('db2',$link2); mysql_set_charset('latin1',$link1); mysql_set_charset('utf8',$link2); http://php.net/manual/en/function.mysql-set-charset.php

« previous php.notes (#152729) next »