Dynadot โ€” .com Registration $8.99

Strange error

Spacemail by SpaceshipSpacemail by Spaceship
Watch

Barrucadu

Established Member
Impact
64
PHP:
<?php

//Update the DB
include 'Includes/DBconnect.php';

$date = date("Y-m-d");
$sql = 'select * from stats_1 where dte="'.$date.'" limit 1';
$sql2 = 'select * from stats_2 where ip="'.$_SERVER['REMOTE_ADDR'].'" limit 1';
$sql3 = 'insert into stats_1 values("'.$date.'","1","'.$unique.'")';
$sql4 = 'insert into stats_2 values("'.$_server['REMOTE_ADDR'].'")';
$sql5 = 'UPDATE stats_1 SET uniqs="'.$uniques.'", visits="'.$visits.'" where dte="'.$date.'"';

mysql_connect($DBhostname,$DBusername,$DBpassword);
mysql_select_db($DBname);
$result = mysql_query($sql) or die($sql." - ".mysql_error());
$result2 = mysql_query($sql2) or die($sql2." - ".mysql_error());
mysql_close();

$num = mysql_num_rows($result);
$num2 = mysql_num_rows($result2);

if($num == 0){
	if($num2 == 0){
		$unique = 1;
		mysql_connect($DBhostname,$DBusername,$DBpassword);
		mysql_select_db($DBname);
		mysql_query($sql4) or die($sql4." - ".mysql_error());
		mysql_close();
	}else{
		$unique = 0;
	}
	mysql_connect($DBhostname,$DBusername,$DBpassword);
	mysql_select_db($DBname);
	mysql_query($sql3) or die($sql3." - ".mysql_error());
	mysql_close();

}else{
	if($num2 == 0){
		$unique = 1;
		mysql_connect($DBhostname,$DBusername,$DBpassword);
		mysql_select_db($DBname);
		mysql_query($sql4) or die($sql4." - ".mysql_error());
		mysql_close();
	}else{
		$unique = 0;
	}
	$visits = mysql_result($result,0,'visits');
	$uniques = mysql_result($result,0,'uniqs');
	$uniques + $unique;
	mysql_connect($DBhostname,$DBusername,$DBpassword);
	mysql_select_db($DBname);
	mysql_query($sql5) or die($sql5." - ".mysql_error());
	mysql_close();
}

?>

now that script should add the persons IP to the table stats_2 if they havent visited before and update the table stats_1 accordingly, but when I run it it adds a blank entry to stats_2 and adds an entry to stats_1 which is perfect apart from the fact that it says 0 uniques..
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
bump, i still need help you know....
 
0
•••
Dynadot โ€” .com Registration $8.99Dynadot โ€” .com Registration $8.99
Appraise.net
Unstoppable Domains
Domain Recover
DomainEasy โ€” Payment Flexibility
  • The sidebar remains visible by scrolling at a speed relative to the pageโ€™s height.
Back