Hola amigos, les queria decir si me pueden ayudar con un codigo que puse en mi web para un contador de visitas con imagenes propias, me da este error:
Warning: mysql_connect() [function.mysql-connect]: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) in /home/webcindario/x/x/xxx/contador/counter.php on line 32
Warning: mysql_select_db() [function.mysql-select-db]: Access denied for user 'apache'@'192.168.0.63' (using password: NO) in /home/webcindario/x/x/xxx/contador/counter.php on line 33
Warning: mysql_select_db() [function.mysql-select-db]: A link to the server could not be established in /home/webcindario/x/x/xxx/contador/counter.php on line 33
Warning: mysql_query() [function.mysql-query]: Access denied for user 'apache'@'192.168.0.63' (using password: NO) in /home/webcindario/x/x/xxx/contador/counter.php on line 47
Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /home/webcindario/x/x/xxx/contador/counter.php on line 47
Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in /home/webcindario/x/x/xxx/contador/counter.php on line 47
Warning: mysql_query() [function.mysql-query]: Access denied for user 'apache'@'192.168.0.63' (using password: NO) in /home/webcindario/x/x/xxx/contador/counter.php on line 73
Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /home/webcindario/x/x/xxx/contador/counter.php on line 73
Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in /home/webcindario/x/x/xxx/contador/counter.php on line 73
Warning: mysql_query() [function.mysql-query]: Access denied for user 'apache'@'192.168.0.63' (using password: NO) in /home/webcindario/x/x/xxx/contador/counter.php on line 81
Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /home/webcindario/x/x/xxx/contador/counter.php on line 81
Warning: mysql_query() [function.mysql-query]: Access denied for user 'apache'@'192.168.0.63' (using password: NO) in /home/webcindario/x/x/xxx/contador/counter.php on line 83
Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /home/webcindario/x/x/xxx/contador/counter.php on line 83
Y el codigo PHP del contador de visitas es:
<--- Inicio Codigo --->
<?php
//Include configuration file
//(default location is in the same directory)
include('config.php');
//Function to get user ip
function get_user_ip(){
$ipParts = explode(".", $_SERVER['REMOTE_ADDR']);
if ($ipParts[0] == "165" && $ipParts[1] == "21") {
if (getenv("HTTP_CLIENT_IP")) {
$ip = getenv("HTTP_CLIENT_IP");
} elseif (getenv("HTTP_X_FORWARDED_FOR")) {
$ip = getenv("HTTP_X_FORWARDED_FOR");
} elseif (getenv("REMOTE_ADDR")) {
$ip = getenv("REMOTE_ADDR");
}
} else {
return $_SERVER['REMOTE_ADDR'];
}
return $ip;
}
//Get User IP
$user_ip = get_user_ip();
//If we need to connect to database, do so
if($STORAGE_TYPE == 2){
$dbc = mysql_connect ($DATABASE_INFORMATION['hostname'],
$DATABASE_INFORMATION['username'],
$DATABASE_INFORMATION['password']);
mysql_select_db($DATABASE_INFORMATION['databasename']);
}
//Get current counter number
if($STORAGE_TYPE == 1){
$file = fopen($FILE_LOCATION,'r');
while($total = fread($file,1025647)){
$counter .= $total;
}
fclose($file);
if(!is_numeric($counter)){$counter = '0';}
} else {
$get_count = "SELECT `".$DATABASE_INFORMATION['fieldname']."`
FROM `".$DATABASE_INFORMATION['tablename']."`";
$num_count = mysql_fetch_row(mysql_query($get_count));
$counter = $num_count[0];
}
//If counting unique visitors
if($SYSTEM_TYPE == 1){
//No match
$match = false;
if($STORAGE_TYPE == 1){
$file = fopen($IP_FILE_LOCATION,'r');
while($total = fread($file,1025647)){
$ip_list .= $total;
}
fclose($file);
$temp_lines = explode("n",$ip_list);
foreach($temp_lines as $line){
if($line == $user_ip){
$match = true;
}
}
if($match == false){
$counter++;
}
} else {
$get_ips = "SELECT COUNT(*) FROM `".$DATABASE_INFORMATION['iptable']."`
WHERE `".$DATABASE_INFORMATION['ipfieldname']."`='$user_ip'";
$check_number = mysql_fetch_row(mysql_query($get_ips));
if($check_number[0] > 0){
$match = true;
} else {
$counter++;
//Update IP list
$insert = "INSERT INTO `".$DATABASE_INFORMATION['iptable']."`
(`".$DATABASE_INFORMATION['ipfieldname']."`) VALUES ('$user_ip')";
$insert_ip = mysql_query($insert);
$update = mysql_query("UPDATE `".$DATABASE_INFORMATION['tablename']."`
SET `".$DATABASE_INFORMATION['fieldname']."`='$counter'");
}
}
} else {
$counter++;
if($STORAGE_TYPE == 1){
//Update IP list
$file = fopen($IP_FILE_LOCATION,'a');
fwrite($file,$user_ip."n");
fclose($file);
//Update Counter list
$file = fopen($FILE_LOCATION,'w');
fwrite($file,$counter);
fclose($file);
} else {
//Update IP list
$insert = "INSERT INTO `".$DATABASE_INFORMATION['iptable']."`
(`".$DATABASE_INFORMATION['ipfieldname']."`) VALUES ('$user_ip')";
$insert_ip = mysql_query($insert);
$update = mysql_query("UPDATE `".$DATABASE_INFORMATION['tablename']."`
SET `".$DATABASE_INFORMATION['fieldname']."`='$counter'");
}
}
//Show counter
switch($USE_IMAGE){
case 1;
for($x=0;$x<strlen($counter);$x++){
$cur_num = substr($counter,$x,1);
echo '<img src="styles/'.$IMAGE_FOLDER[0].'/'.$cur_num.'.'.$IMAGE_FOLDER[1].'" title="'.$counter.'" alt="'.$counter.'">';
}
break;
case 2;
echo "Site Counter: $counter";
break;
}
?>
<--- Fin Codigo --->
Espero que me ayuden, desde ya gracias.