rmmarsh
asked on
Why won't this script recognize the parameter?
I am calling this script by the following statement (in a browser):
http://www.mysite.com/clickCounter/count.php?http://www.mysite.com/downloads/PragerInventorySetup.exe
It was working fine on a Windows server; I just switched to a Linux server and now this...
http://www.mysite.com/clickCounter/count.php?http://www.mysite.com/downloads/PragerInventorySetup.exe
It was working fine on a Windows server; I just switched to a Linux server and now this...
<?php
$COUNT_FILE = "data.txt"; // En: Absolute path and name to count data file.
function error ($error_message) {
echo $error_message."<BR>";
exit;
}
echo $QUERY_STRING."<br>";
$url = urldecode($QUERY_STRING); // get the passed URL
if (! file_exists($COUNT_FILE))
error("Can't find data file, check '\$COUNT_FILE' var...");
if ((! $url) || (! preg_match("/http:/", $url)))
error ("The URL you passed is invalid (doesn't begin with http:)");
$file_arry = file($COUNT_FILE); // read each line of data from count.txt file into array
//list($key, $val) = each($file_arry);
//echo "key=".$key."<BR>";
//echo "val=".$val."<BR>";
while (list($key, $val) = each($file_arry)) { // parse each line into key/value pairs
if ($val != "") { // if URL is not blank...
list($file_url, $nb) = preg_split("/\t|\n/", $val);
if ($file_url == $url) {
$nb += 1;
$file_arry[$key] = "$file_url\t$nb\n";
$find = 1;
}
}
}
$file = join ("", $file_arry);
//if (! $find) // if URL wasn't found, put new URL into file
// $file .= "$url\t1\n";
$fp = fopen("$COUNT_FILE", "w");
flock($fp, LOCK_EX + LOCK_NB);
fputs($fp, $file);
flock($fp, LOCK_UN);
fclose($fp);
header("Location: $url");
?>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hielo: that seems to do the job... but now it won't find the file, so I have some homework to do before I award points... will get back to you tomorrow.
Thanks...
Thanks...
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hmmm... deleted the file (because it was old, and will upload new ones tonight when I get home) and am now getting this warning:
Warning: Cannot modify header information - headers already sent by (output started at /home/wwwmar1/public_html/ clickCount er/count.p hp:10) in /home/wwwmar1/public_html/ clickCount er/count.p hp on line 47
What do I do to fix this?
Warning: Cannot modify header information - headers already sent by (output started at /home/wwwmar1/public_html/
What do I do to fix this?
ASKER
Line 47 above refers to line 91 in attached code snippet
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
That did it also... I'm gonna get my PHP textbook out and start reading; would be nice to know why I'm doing something!
Thanks again!
Thanks again!
>>would be nice to know why I'm doing something!
LOL. I hear you!
>>Thanks again!
You are welcome!
LOL. I hear you!
>>Thanks again!
You are welcome!
maybe your script relies on register_globals to be turned on?