trouble with simple "logfile"-script

From: Date: Sat, 10 Nov 2001 22:52:42 +0000
Subject: trouble with simple "logfile"-script
Groups: php.db 
Request: Send a blank email to php-db+get-14221@lists.php.net to get a copy of this message
Hi all, I use a small php-script for generating some simple weekly weblog for a site with about 3.000 vists / day. I do not want to log IP or dates, I just want to count pageimpressions for all the html/php-files seperately. A friend helped me with the script, but although it does exactly what I want, we have some trouble with it: For every page we have an entry in the sql-database with fields for page (seite) / week (kw) / number of hits (anzahl). Sometimes the script inserts a new entry, so that there are two, three or even twenty entries for the same page in the same week. As you will see the code checks if there is already an entry for the actual file / actual week, and if so it should just counts hits. Sometimes (on the average two times a day) the script generates a new entry and then logs in both, the original entry and the new, false one. Two days ago it started creating so many new entries that my isp had to block the database because it consumed to much server-ressources... Any help would be very appreciated. Torsten setlocale("LC_TIME","de"); $kw=strftime("%W"); if(!isset($id)) $id = "NN"; $logdata=$bloede->select("select * from bloede_log where kw = $kw AND seite ='$id'"); if(sizeof($logdata) == 0) $bloede->insert("insert into bloede_log (kw, seite, anzahl) values ($kw, '$id', 1)"); else $bloede->insert("update bloede_log set anzahl = (anzahl+1) where kw = $kw AND seite = '$id'"); $logdata = ""; if($id == "NN") { Header("Location: index.php4"); exit; }

« previous php.db (#14221) next »