I have a script, that registers anyone that visits the URL, and it redirects to proper url, used to register visits on some links I have. (at the moment one)
Having problems with it though. I have made it insert new data into my MySQL database, and its supposed to do this every time someone visits the URL, although it only inserts a set once, and then stops working.
PHP Code:
<?php
include('db.php');
dbConnect(); $sql = "select filename from dlstats"; $result = mysql_query($sql); $rows = mysql_num_rows($result); for ($x=0;$x<$rows;$x++) { $urlarray[$x] = mysql_result($result,$x); } $request = $urlarray['purchase']; header("Location: http://www.gks.uk.com/buy"); // if ($REMOTE_ADDR == '82.35.196.185'){ date_default_timezone_set('GMT'); $datetime = date('d M Y h:i:s a'); $querystat = "INSERT INTO dlstats SET FileCode='purchase', IP='$REMOTE_ADDR', DateTime='$datetime', StatNo=StatNo+1"; $resultstat = mysql_query($querystat); if (!$result){ echo("Database Error2"); }
if (isset($showme)){ dbConnect(); $query = "SELECT totalhits FROM dlcount WHERE FileCode = $showme"; $result = mysql_query($query); $hitcount = mysql_result($result,0); echo($hitcount); }
// else echo 'IP Skipped (because its mine) '; }
?>
db.php just contains my database configuration.
Can someone please tell me why its only adding data once. And possibly lead me to a fix.
|