Page 1 of 1

Include Problem

Posted: Mon Aug 12, 2002 2:32 pm
by Zeceer
<?php

$dirname = "produkter";
$dh = opendir( $dirname );

while( $file = readdir( $dh ) )
{
include("$file");
}

?>

Why want his work?

This is what I see when running this code:

Warning: Failed opening '.' for inclusion (include_path='.;c:\php4\pear') in D:\inc shop\index.php on line 29

Warning: Failed opening '..' for inclusion (include_path='.;c:\php4\pear') in D:\inc shop\index.php on line 29

Warning: Failed opening 'produkt1.php' for inclusion (include_path='.;c:\php4\pear') in D:\inc shop\index.php on line 29

Warning: Failed opening 'produkt2.php' for inclusion (include_path='.;c:\php4\pear') in D:\inc shop\index.php on line 29

Warning: Failed opening 'produkt3.php' for inclusion (include_path='.;c:\php4\pear') in D:\inc shop\index.php on line 29

I've tried what I know, but nothing seams to work. Please help :oops:

Posted: Mon Aug 12, 2002 2:47 pm
by llimllib
which line is line 29?

Posted: Mon Aug 12, 2002 3:13 pm
by Zeceer
include("$file");

This is line 29 :D

Posted: Mon Aug 12, 2002 3:25 pm
by llimllib
try

Code: Select all

if(is_file("$dirname/$file"))
    include "$dirname/$file";
this time. In the future, read the error messages carefully. PHP is trying to open d:\inc shot\., d:\, and d:\inc shop\produktX.php. If the file you're trying to include isn't in the current execution directory (signified by the '.' in the include_path, by the way), then PHP won't be able to find it unless you direct it to the file.