Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/76.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
为什么在php if语句中出现标题信息错误?_Php_Html_Mysql - Fatal编程技术网

为什么在php if语句中出现标题信息错误?

为什么在php if语句中出现标题信息错误?,php,html,mysql,Php,Html,Mysql,可能重复: 好的,我得到这个错误: Warning: Cannot modify header information - headers already sent by (output started at /home/content/91/9646291/html/quotesystem/cpanel/index.php:1) in /home/content/91/9646291/html/quotesystem/cpanel/index.php on line 11 Noti

可能重复:

好的,我得到这个错误:

Warning: Cannot modify header information - headers already sent by (output started at   
/home/content/91/9646291/html/quotesystem/cpanel/index.php:1) in 
/home/content/91/9646291/html/quotesystem/cpanel/index.php on line 11

Notice: Undefined variable: content in 
/home/content/91/9646291/html/quotesystem/cpanel/index.php on line 63

Warning: include() [function.include]: Filename cannot be empty in 
/home/content/91/9646291/html/quotesystem/cpanel/index.php on line 63

Warning: include() [function.include]: Failed opening '' for inclusion 
(include_path='.:/usr/local/php5_3/lib/php') in 
/home/content/91/9646291/html/quotesystem/cpanel/index.php on line 63
这是页面上的代码:
//Check USER LOGIN IF not logged in bring to login screen else display content
if (!(checkUser())){
    header('Location: /quotesystem/index.php');

}else{

    //Get the user array to display data 
    $userArray = getUserArray();

    //Make sure that the userid in the browser is the same as current loggin in user
    if($userArray['user_id'] != $uid){

        $content = '';

        $view = (isset($_GET['view']) && $_GET['view'] != '') ? $_GET['view'] : '';

        switch ($view) {
            case 'list' :
                $content    = 'list.php';       
                $pageTitle  = 'Customer Control Panel - View Product';
                break;

            case 'changepass' :
                $content    = 'includes/changePass.php';        
                $pageTitle  = 'Customer Control Panel - Change Password';
                break;

            case 'modify' :
                $content    = 'includes/modify.php';        
                $pageTitle  = 'Customer Control Panel - Modify Product';
                break;

            case 'detail' :
                $content    = 'detail.php';
                $pageTitle  = 'Customer Control Panel - View Product Detail';
                break;

            default :
                $content    = 'main.php';       
                $pageTitle  = 'Customer Control Panel - View Info';
        }

                    if(!($content) OR $content =='') {
                        $content = 'main.php';
                        $pageTitle = 'Customer Cpanl';
                    }

    }else {
        echo  "Sorry this is for the customer's eyes only...you are being redirected to the <a href=\"http://www.domain.com/quotesystem\">homepage</a>.     ";


    }
}
include $content;

include('../admin/footer.php');
?>
//如果未登录,请检查用户登录,然后转到登录屏幕,否则显示内容
如果(!(checkUser())){
标题('Location:/quotesystem/index.php');
}否则{
//获取用户数组以显示数据
$userArray=getUserArray();
//确保浏览器中的用户ID与当前登录用户相同
if($userArray['user\u id']!=$uid){
$content='';
$view=(isset($获取['view'])和&$获取['view']!='')$获取['view']:'';
交换机($view){
个案"名单":
$content='list.php';
$pageTitle='客户控制面板-查看产品';
打破
案例“变更通行证”:
$content='includes/changePass.php';
$pageTitle='客户控制面板-更改密码';
打破
案例“修改”:
$content='includes/modify.php';
$pageTitle='客户控制面板-修改产品';
打破
案例“细节”:
$content='detail.php';
$pageTitle='客户控制面板-查看产品详细信息';
打破
违约:
$content='main.php';
$pageTitle='客户控制面板-查看信息';
}
如果(!($content)或$content=''){
$content='main.php';
$pageTitle='Customer Cpanl';
}
}否则{
echo“抱歉,这只是为了客户的眼睛……您被重定向到了。”;
}
}
包括$content;
包括('../admin/footer.php');
?>
流程如下:如果用户已登录(如果已登录,则checkUser()返回true;如果未登录,则返回false)
然后,如果当前用户id与url中的用户id匹配,它将显示内容。如果没有,它会显示消息并重定向。

我怀疑您的实际问题是:

if($userArray['user_id'] != $uid){ // is $uid even set ever?  is the $userArray set with the right user_id?

因为如果这些返回正确的布尔值,$content变量将永远不会被设置,并且您将得到
include(“”)的错误


一般来说,我建议设置测试,或者它们的小兄弟断言,以确保获得正确的逻辑流。此外,尽早广泛地设置默认值。这些步骤将有助于降低调试复杂性。

我发现翻转逻辑和使用javascript重定向都非常成功

if (checkUser()){
  Display the content
 }else{
echo "<script type='text/javascript'> window.location = 'http://www.domain.com/quotesystem'</script>";
}
if(checkUser()){
显示内容
}否则{
回显“window.location”http://www.domain.com/quotesystem'";
}

在$content中设置了什么?您包含的文件会发生什么情况?内容当前是默认的,我刚刚发现它在默认页面上确实发生了更改,现在它不允许我更改标题警告:无法修改标题信息-标题已由发送(输出开始于/home/content/91/9646291/html/quotesystem/cpanel/index.php:1)在第11I行的/home/content/91/9646291/html/quotesystem/cpanel/index.php中,我也会查看您的htaccess/apache重定向,并尝试使用另一种浏览器,因为页面的html很可能会与旧的/损坏的或类似的内容一起缓存。好的,我也会研究一下,然后它不会显示其他回音错误可能很容易覆盖整个回音。我怀疑php是否愿意给出任何无错误的输出,如果给它一个空白或空的include路径,它可能会在代码中出错,并跳过为您回显任何信息。
if (checkUser()){
  Display the content
 }else{
echo "<script type='text/javascript'> window.location = 'http://www.domain.com/quotesystem'</script>";
}