Need help with require_once on IIS

Status
Not open for further replies.

DewChugr

Photoshop God
Jun 26, 2006
1,977
66
0
48.655139,-119.644032
It sucks, but I have to get this working on an IIS machine. :(

I have a php script that outputs the pdf files in a directory. It works fine on an Apache server, but blows chunks on IIS with PHP 4.3.10

This works
<? require_once('includes/dir.php'); ?>

This works<a href="includes/dir.php?dirname=../documents/reports/">Link</a>

This doesn't work
<? require_once('includes/dir.php?dirname=../documents/reports/'); ?>

This is the error
Warning: main(includes/dir.php?dirname=../documents/reports/): failed to open stream: No such file or directory in D:\Production\Site\publications.php on line 52

Fatal error: main(): Failed opening required 'includes/dir.php?dirname=../documents/reports/' (include_path='.;C:\php4\includes\pear;D:\ test\;') in D:\Production\Site\publications.php on line 52

Help me Obi-Wan, your my only hope....
 


Include(_once) and require(_once) do not accept parameters. The file is 'included' not processed before it is included.

So if you try:
a.php:
Code:
   echo "I have something to say:";
  require('b.php?var1=c');
  echo "Doh!";
and b.php contains:
Code:
   $var1 = $_GET['var1'];
  echo "Homer Simpson Rocks!" . $var1;
You get the error.

If you do the following:
a.php:
Code:
   echo "I have something to say:";
  require('b.php');
  echo "Doh!";
and b.php contains:
Code:
   $var1 = $_GET['var1'];
  echo "Homer Simpson Rocks!" . $var1;
The code that will be processed would be:
Code:
   echo "I have something to say:";
  $var1 = $_GET['var1'];
   echo "Homer Simpson Rocks!" . $var1;
   echo "Doh!";
and in this case, $var1 is empty.

Now, if you do a:
Code:
     ob_start();
    eval(file_get_contents('b.php?var1=c')); 
    $text = ob_get_clean();
You may be able to get the intended results...

Good luck! and all code is 100% not-checked or tested.
 
  • Like
Reactions: DewChugr
Thanks for the response, that makes sense.

I got it to work by including the file (modified) and creating a variable with the parameter I was attempting to pass.
 
Status
Not open for further replies.