I'm running on a IIS 6 with PHP 4.2.3. I set up a counter script that records to a mySQL db. Since its IIS, of course it won't accept the easy solution of $SERVER['REQUEST_URI']. I'm using the alternative $SERVER[PHP_SELF]?$HTTP_SERVER_VARS[QUERY_STRING]. It works in some cases but in others it does not. For example, the method works when there is only one variable being passed (i.e. index.php?id=1) but not when there are two (i.e. index.php?sid=1&cid=1). In the latter case only index.php? shows up. The following is the code for the counter. Thanks for any help.
function counter($page)
{
$mysql = mysql_connect("localhost","user","pass");
mysql_select_db("theVoyeur",$mysql);
$query = "INSERT INTO counter (ip,referer,page,agent,datetime,date,time) VALUES ('$_SERVER[REMOTE_ADDR]','$_SERVER[HTTP_REFERER]','$_SERVER[PHP_SELF]?$HTTP_SERVER_VARS[QUERY_STRING]','$_SERVER[HTTP_USER_AGENT]',NOW(),CURDATE(),CURTIME())";
$query2 = "INSERT INTO counterHits (page) VALUES ('$_SERVER[PHP_SELF]?$HTTP_SERVER_VARS[QUERY_STRING]')";
$query3 = "UPDATE counterHits SET hits = hits + 1 WHERE page = '$_SERVER[PHP_SELF]?$HTTP_SERVER_VARS[QUERY_STRING]'";
mysql_query($query,$mysql);
mysql_query($query2,$mysql);
mysql_query($query3,$mysql);
if($page=="none")
{
return;
}
else
{
$result = mysql_query("SELECT count(id) FROM counter WHERE page = '$page'",$mysql);
$counter = mysql_fetch_row($result);
return $counter[0];
} mysql_close($mysql);
}