I'm trying to pass a parameter from php file#1 (
index.php ) to php file#2 (
/scripts/make_links.php)
The concept:
File
index.php can be in any directory.
index.php uses
include() or
require_once() to, um, include
/scripts/make_links.php (in a static location)
index.php gets the current directory and passes it to the included file
/scripts/make_links.php /scripts/make_links.php processes files in the directory where
index.php is located
The code below only attempts to
- get the variable passed
- have the second file echo the variable.
If it can do that, it can do all I want it to do. I know this because
make_links.php works as expected if I hard-code the variable into
make_links.php
index.php (in any directory)
<?php
$curra = substr(getcwd(),25);
$curr =$_GET['curra'];
require_once("http://www.mydomain.com/scripts/make_links.php");
?>
/scripts/make_links.php (static location = /scripts)
<?php
print "<BR />";
print "curr is ";
print $curr;
print "<BR />";
?>
My concept and/or code is/are not working.
[font="Courier New"]index.php
<?php
The next line works correctly. index.php extracts the last portion of the directory name:
$curra = substr(getcwd(),25);
I can't tell if he next line works correctly. $curr =$_GET['curra']; The next line works correctly. /scripts/make_links.php does run: /scripts/make_links.phprequire_once("http://www.mydomain.com/scripts/make_links.php");
?>
Unfortunately, while
make_links.php does run, it does not recognize the variable containing the directory name and does not process the files in that directory.
Can someone help me find the right way to do this?