Link to home
Start Free TrialLog in
Avatar of rmmarsh
rmmarshFlag for United States of America

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...
<?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");
 
 
 
?>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of hielo
hielo
Flag of Wallis and Futuna image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Try $_SERVER["QUERY_STRING"]

maybe your script relies on register_globals to be turned on?
Avatar of rmmarsh

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...
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rmmarsh

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/clickCounter/count.php:10) in /home/wwwmar1/public_html/clickCounter/count.php on line 47

What do I do to fix this?
Avatar of rmmarsh

ASKER

Line 47 above refers to line 91 in attached code snippet
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rmmarsh

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!
>>would be nice to know why I'm doing something!
LOL. I hear you!

>>Thanks again!
You are welcome!