Welcome to HBH! If you have tried to register and didn't get a verification email, please using the following link to resend the verification email.

include_once problems


ghost's Avatar
0 0

Hi all,

Im working on a website, and im having some problems with the include system. I take (and clean) the page variable, and can echo the results to the page just fine. I can also include and include_once the page fine, but when I try and add or die() at the end, I get this error:

Warning: include_once(1) [function.include-once]: failed to open stream: No such file or directory in /home/freehost/t35.com/p/r/projectvault/index.php on line 23

Warning: include_once() [function.include]: Failed opening '1' for inclusion (include_path='.:/usr/local/lib/php') in /home/freehost/t35.com/p/r/projectvault/index.php on line 23

I think its evaluating it as an or statement, but I dont know why the $page variable is being affected. Here is the code:

<?php
        if(isset($_GET['page'])) {
            $page = "./".ficlean($_GET['page']).".php";
            include_once($page) *or die()*;
        } else {
            include_once("main.php");
        }
        ?>

Any ideas?


ghost's Avatar
0 0

Edit - Just do this:

if (isset($_GET['page']) { $page = "./".ficlean($_GET['page']).".php"; }

if ($page && file_exists($page)) { include_once($page); } else { include_once($otherInclude); }


ghost's Avatar
0 0

Thanks, I guess il have to do it the long way, Im still curious as to why this is happening though. Might it be a bug in the PHP version? Its a t35 site, so I would have thought it would be fine.


ghost's Avatar
0 0

Just noticed… it looks like your script is reading the $_GET['page'] as being equal to 1. Are you sure that your GET variable is being entered / parsed correctly?