<?php
$dbhost="localhost";
$dbname="l2";
$dbuser="root";
$dbpass="";
$lin=mysql_connect($dbhost,$dbuser,$dbpass) or die("Нету подключения к серверу MySqL");
mysql_select_db($dbname,$lin) or die("Нету подключения к серверу MySqL");
mysql_query("SET NAMES utf8");
mysql_query("set character_set_client='utf8'");
mysql_query("set character_set_results='utf8'");
mysql_query("set collation_connection='utf8'");
error_reporting(E_ALL);
ini_set('display_errors',0); 
set_error_handler('user_log');
function user_log ($errno, $errmsg, $file, $line) {
 $timestamp = time();
 $err_str = $timestamp.'||';
 $err_str .= $errno.'||'; 
 $err_str .= $file.'||'; 
 $err_str .= $line.'||'; 
 $err_str .= $errmsg."\n"; 
 if (is_file(ERROR) AND filesize(ERROR)>=(LOG_FILE_MAXSIZE*1024)) {
 if (LOG_ROTATE===true) {
 $i=1;
 while (is_file(ERROR.'.'.$i)) { $i++; }
 $i--;
 while ($i>0) {
 rename(ERROR.'..'.$i,ERROR. '.' .(1+$i--));
 }
 rename (ERROR,ERROR.'.1');
 touch(ERROR);
 }
 elseif(is_file(ERROR)) {
 unlink(ERROR);
 touch(ERROR);
 }
 }
 if(!is_file(ERROR)) {
 if (!touch(ERROR)) {
 return 'can\'t create log file';
 }
 }
 elseif(!is_writable(ERROR)) {
 return 'can\'t write to log file';
 }
 error_log($err_str, 3, ERROR);
}

?>