Warning: include() [function.include]: Filename cannot be empty PHP

The PHP file worked fine with no errors on my local server on MAMP, but when I uploaded it to my schools web server and tried to run the page I get these error messages, but it is working , its just giving me these errors

Warning: include() [function.include]: Filename cannot be empty in /home//inc/header.php on line 57

Warning: include() [function.include]: Failed opening '' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in //public_html/inc/header.php on line 57

The source the last line is line 57 where it says the error is occurring

<?php
    if(isset($_GET["page"])){
        if($_GET["page"] == "home"){
            $pageTitle = "Home Page";
            $page = null;
        }else if($_GET["page"] == "aboutus"){
            $pageTitle = "About Us";
            $page  = "aboutus.php";
        }else if($_GET["page"] == "contact"){
            $pageTitle = "Contact Us";
            $page  = "contact.php";
        }else if($_GET["page"] == "portfolio"){
            $pageTitle = "Portfolio";
            $page  = "portfolio.php";
        }else if($_GET["page"] == "services"){
            $pageTitle = "Services";
            $page  = "services.php";
        }
    }
?>

<title><?php echo $pageTitle;?></title>

<?php include($page) ;?>    <!-- different pages load content -->   

you don't get it on your local machine because you're developing with error_reporting disabled in php.ini. don't do that, always develop with error_reporting=E_ALL

meanwille, you get the errors on your schools website, because its NOT running with error_reporting disabled. fix your local machine and you'll get this eror there too.

and the error is trying to tell you that NULL is not a valid argument for include, that's an error in your code. so fix that.

<?php if(isset($page)){include($page);} ?>

now it will never try to include $page if $page is NULL, and you wont get that error anywhere. but seriously, fix your php.ini, it helps you detect a lot of bugs (like this one) while developing.

链接地址: http://www.djcxy.com/p/69676.html

上一篇: PHP解析错误

下一篇: 警告:include()[function.include]:文件名不能为空PHP