Topic: MySQL set names fix
function DBLayer($db_host, $db_username, $db_password, $db_name, $db_prefix, $p_connect)
{
$this->prefix = $db_prefix;
if ($p_connect)
$this->link_id = @mysql_pconnect($db_host, $db_username, $db_password);
else
$this->link_id = @mysql_connect($db_host, $db_username, $db_password);
if ($this->link_id)
{
if (@mysql_select_db($db_name, $this->link_id))
return $this->link_id;
else
error('Unable to select database. MySQL reported: '.mysql_error(), __FILE__, __LINE__);
}
else
error('Unable to connect to MySQL server. MySQL reported: '.mysql_error(), __FILE__, __LINE__);
// Setup the client-server character set (UTF-8)
if (!defined('PUN_NO_SET_NAMES'))
mysql_query('SET NAMES \'utf8\'', $this->link_id) or error(__FILE__, __LINE__);
}
Set utf-8 before DB select.
function DBLayer($db_host, $db_username, $db_password, $db_name, $db_prefix, $p_connect)
{
$this->prefix = $db_prefix;
if ($p_connect)
$this->link_id = @mysql_pconnect($db_host, $db_username, $db_password);
else
$this->link_id = @mysql_connect($db_host, $db_username, $db_password);
// Setup the client-server character set (UTF-8)
if (!defined('PUN_NO_SET_NAMES'))
mysql_query('SET NAMES \'utf8\'', $this->link_id) or error(__FILE__, __LINE__);
if ($this->link_id)
{
if (@mysql_select_db($db_name, $this->link_id))
return $this->link_id;
else
error('Unable to select database. MySQL reported: '.mysql_error(), __FILE__, __LINE__);
}
else
error('Unable to connect to MySQL server. MySQL reported: '.mysql_error(), __FILE__, __LINE__);
}
And utf work.
Royal Crown Chinpoko Master, ^_^