function connect($host, $username, $password)
{
$result = @mysql_connect($host, $username, $password);
if (!$result)
{
$error = $this->display_error(MSG_ERROR_MYSQL_CONNECT, $this->sql_error());
if ($this->die)
{
die ($error);
}
else
{
return false;
}
}
else
{
$version = mysql_get_server_info($result);
if(preg_match('/^5\./',$version) || preg_match('/^4\.[1-9]/',$version)){
if(preg_match('/^5\./',$version)) mysql_query('set session sql_mode=0');
mysql_query('set names cp1251');
mysql_query('set character set cp1251');
mysql_query('set character_set_client=cp1251');
mysql_query('set character_set_results=cp1251');
mysql_query('set character_set_connection=cp1251');
mysql_query('set character_set_database=cp1251');
mysql_query('set character_set_server=cp1251');
}
return true;
}
}