мой класс работы с базой
header('Content-Type: text/html; charset=utf8');
include_once (ROOT_DIR.'global.php');
Class MySQL{
public function __construct(){
$result=mysql_connect(DB_HOST, DB_NAME, DB_PASS) or die("Error: Can't connect to MySQL!");
@mysql_query ("set character_set_client='".CHARACTER."'");
@mysql_query ("set character_set_results='".CHARACTER."'");
@mysql_query ("set collation_connection='".CHARACTER_FULL."'");
$result.=mysql_select_db(DB_NAME) or die("Error: There is no database with the same name!");
mysql_query("SET NAMES '".CHARACTER."'");
return $result;
}
static public function query($query,$r= null,$mf =null){
$result=mysql_query($query) or die(mysql_error());
if(!$r or $r=='res'){
return $result;
}elseif($r=='row' && $mf == 'array'){
$row = mysql_fetch_array($result);
return $row;
}elseif($r=='row' && $mf == 'cont'){
$row = mysql_fetch_assoc($result);
return count($row);
}elseif($r=='row' && $mf == 'assoc'){
$row = mysql_fetch_assoc($result);
return $row;
}
}
public function __destruct(){
mysql_close();
}
}
вход
public function enter($login, $upass){
$MySql = new MySQL();
$protection = new protections();
$global_function = new global_function();
$languages = new languages();
$this->ulogin= $protection->sip($login);
$password= $protection->sip($global_function->hiddenpassword($global_function->rus2translit($password)), true);
$this->upassword = $protection->mdmdsha($password.$this->ulogin.SALT);
if($total = $MySql->query("SELECT * FROM ".PREF."users WHERE ulogin='".$this->ulogin."' AND upassword='".$this->upassword."'", 'row', 'cont') != 1){return $languages->output_languages('3');}else{
$row = $MySql->query("SELECT * FROM ".PREF."users WHERE ulogin='".$this->ulogin."'", 'row', 'assoc');
setcookie('id', ''.$row['id'].'',time()+(315360000), "/");
setcookie('name', ''.$row['name'].'',time()+(315360000), "/");
setcookie('ulogin', ''.$this->ulogin, "/");
setcookie('upassword_cookie', ''.$protection->sip($protection->mdmdsha($this->upassword.$row['salt'].$row['id'].$this->ip).'',time()+(315360000), true), "/");
unset($row);
unset($MySql);
return true;
}
}
выдает
Warning: mysql_query() [function.mysql-query]: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) in /home/www/z26/htdocs/di-it.ru/system/includes/MySql.php on line 16
Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /home/www/z26/htdocs/di-it.ru/system/includes/MySql.php on line 16
Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
Warning: mysql_close(): no MySQL-Link resource supplied in /home/www/z26/htdocs/di-it.ru/system/includes/MySql.php on line 33
Подскажите пожалуйста, в чем причина? и как исправить?