Page 1 of 1

Passing on values when opening a file with file()?

Posted: Thu Sep 27, 2007 4:40 am
by mikebr
I wonder if there is a way of passing on values when opening a file?

I have a script on a domain that does some calculations from the database on that domain, I access this script from another domain using the following code:

Code: Select all

$THE_STRING = file("http://domain/folder/php/get_data_calc.php?l=$l&d=$d&m=$m&y=$y");

$data_array = explode("|",$THE_STRING[0]);
print_r ($data_array);
The array $data_array returns the default values for the data as it does not pick up the variables passed in the URL, anyone know if there is a way of picking these passed variables up in get_data_calc.php?

I have tried using $_GET in the get_data_calc.php file but that does not work, also tried using
$theurl = $_SERVER['REQUEST_URI']; then breaking up $theurl to get the variable values but using $_SERVER['REQUEST_URI'] just stops the script from running in this case.

Do I have any other options on this?

Posted: Thu Sep 27, 2007 7:12 am
by volka
What does

Code: Select all

$source = "http://domain/folder/php/get_data_calc.php?l=$l&d=$d&m=$m&y=$y"
echo 'source: ', $source, "<br />\n";
$THE_STRING = file($source);

$data_array = explode("|",$THE_STRING[0]);
print_r ($data_array);
print?

Posted: Thu Sep 27, 2007 1:07 pm
by mikebr
volka,

I never even thought of doing it that way... is it not just basically the same thing?
anyway it seems to work so obviously not!

Many thanks

Posted: Thu Sep 27, 2007 2:36 pm
by volka
It only echos the url before passing it to file() - for debug purposes. It fixes nothing.

Posted: Thu Sep 27, 2007 2:43 pm
by mikebr
Puzzeled, this does not work:

Code: Select all

$THE_STRING = file("http://domain/folder/php/get_data_calc.php?l=$l&d=$d&m=$m&y=$y"); 

$data_array = explode("|",$THE_STRING[0]); 
print_r ($data_array);
but this does:

Code: Select all

$SOURCE = "http://domain/folder/php/get_data_calc.php?l=$l&d=$d&m=$m&y=$y"; 

$THE_STRING = file($SOURCE);

$data_array = explode("|",$THE_STRING[0]); 
print_r ($data_array);
?

Posted: Thu Sep 27, 2007 2:49 pm
by volka
a miracle.