Anyone have an idea why I dont have any output on this on?
Maybe there are some flaws in the script, since I dont have output I cant control it.
so...any help would be appreciated.
include ("db_connect.inc");
if (!mysql_select_db('counter')) die(mysql_error);
$REMOTE_ADDR = $HTTP_SERVER_VARS['REMOTE_ADDR'];
$sql = "SELECT * FROM IP_STATS WHERE IP_ADDRESS = '$REMOTE_ADDR'";
$result = mysql_query($sql, $link_id) or die("Problem with select query: ".mysql_error());
$row = mysql_fetch_assoc($result);
if ($row['IP_ADDRESS'] !== '$REMOTE_ADDR')
{
$PERCENTAGE=$row['HITS_IP']/100*100;
$REMOTE_ADDR = $HTTP_SERVER_VARS['REMOTE_ADDR'];
mysql_query("Update IP_STATS
SET IP_ADDRESS=$REMOTE_ADDR,
HITS_IP=HITS_IP+1,
PERCENTAGE=$PERCENTAGE,
WHERE IP_ADDRESS='$REMOTE_ADDR'");
}
else if ($row['IP_ADDRESS'] == '$REMOTE_ADDR')
{
$PERCENTAGE=$row['HITS_IP']/$row['TOTAL_VISITS']*100;
$HITS_IP = 1;
$sql = "INSERT into IP_STATS (HITS_IP, PERCENTAGE) VALUES ('$HITS_IP', '$PERCENTAGE')";
$result = mysql_query($sql, $link_id) or die("Problem with query: ".mysql_error());
}
mysql_query("Update IP_STATS
SET TODAY_HITS=TODAY_HITS+1,
MONTH_HITS=MONTH_HITS+1,
TOTAL_VISITS=TOTAL_VISITS+1,
UNIQUE_VISITS=UNIQUE_VISITS+1");
$sql = "SELECT * FROM IP_STATS ORDER BY HITS_IP";
$result = mysql_query($sql, $link_id) or die("Problem with select query: ".mysql_error());
while ( $row = mysql_fetch_array($result) ) {
echo $row['IP_ADDRESS'];
}
maybe my table has some errors, so i put it here.
CREATE TABLE IP_STATS (
ID INT(20) NOT NULL auto_increment,
IP_ADDRESS varchar(60) NOT NULL default '',
HITS_IP int(11),
PERCENTAGE INT CHECK ((Percentage > 0) AND (Percentage <= 100)),
TODAY_HITS int(11),
MONTH_HITS int(11),
TOTAL_VISITS int(11),
UNIQUE_VISITS int(11),
PRIMARY KEY (id))
TYPE=MyISAM";
This is just a counter scipt.
check if IP is in DB if true update some counters
and if false update also update some counter.
Now would I like to have an output ordered on HITS_IP, so I can see what IP_adres has the most hits.
Like this
IPaddress__most hits ip____highest percentage
and a table with todays hits, this month hits, total hits and unique hits.
There is no timeframe yet in the script. need to search for it.
my goal with this question this get to work.
IPaddress__most hits ip____highest percentage