To specify charset in my.cnf file you just have to add
skip-character-set-client-handshake directive after
[mysqld]
default-character-set=utf8
Descrição
Esta função é um apelido para: mysqli::__construct()
User Contributed Notes
mysqli_connect
mysqli_connect
chip1977 at mail dot ru
28-Jan-2008 10:52
28-Jan-2008 10:52
martin dot velek at gmail dot com
30-Jul-2007 01:53
30-Jul-2007 01:53
When you need more(less) timeout, you can use this. This only guarantees that host and port are opened. It is suitable on the very high speed networks(LAN) and where one second is not acceptable.
$timeoutInSeconds can be set to any numeric value
e.g. "1/2", "0.500","0.1","0.01" etc.
--------------------------------------------------------------
function getmicrotime()
{
list($usec, $sec) = explode(" ",microtime());
return ((float)$usec + (float)$sec);
}
$time_start = getmicrotime();
$fp = fsockopen("$mysqlHost",$mysqlPort, $errno, $errstr,$timeoutInSeconds);
if (!$fp)
{
//timeout mostly
echo "ERR: $errno - $errstr<br>\n";
$time_end = getmicrotime();
$time = $time_end - $time_start;
echo "Timeout $time sekund";
}
else
{
fclose($fp);
}
nonerr gmail.com
06-Jul-2007 10:29
06-Jul-2007 10:29
This helped me:
<?php
$db = mysqli_connect($host, $login, $pass, $dbName);
$db->set_charset('utf8');
...
?>
Gazzer
18-Feb-2007 05:52
18-Feb-2007 05:52
Yes, it's totally odd that php.ini doesn't seem to allow you to global specify the client connection as utf-8. You might try this in the
my.cnf file
[client]
default-character-set=utf8
[mysqld]
default-character-set=utf8
It didn't work for me, but others may have better luck. In the end I had to specify in the php code as noted below.
Niel Archer
31-Jan-2007 05:13
31-Jan-2007 05:13
A quick word about the connection encoding for this extension. It doesn't appear to be documented anywhere that I can find, but this defaults to latin1 encoding for the connection, regardless of PHP's or MySQL's settings. I run in a completely UTF-8 setup, and spent days trying to discover the cause of corrupted characters from the Db. If, like me, you need to work with other than latin1, use the set_charset function/method to switch to your encoding of choice.

mysqli_client_encoding