简体   繁体   English

HTTP 错误 500 - php

[英]HTTP ERROR 500 - php

I'm trying to open the index.php page but the browser shows this error: currently unable to handle this request.我正在尝试打开 index.php 页面,但浏览器显示此错误:当前无法处理此请求。 HTTP ERROR 500 HTTP 错误 500

I do not think that the error is on the config.php page because the database configuration works fine with pages other than the index.php我不认为错误出在 config.php 页面上,因为数据库配置适用于 index.php 以外的页面

here is my index.php code:这是我的 index.php 代码:

<?php 
    require_once 'config.php'; 

    login_required(); 
    $users = count_query("SELECT COUNT(*) AS num FROM users"); 
    $emails = count_query("SELECT COUNT(*) AS num FROM subscribers"); 
    $subs = count_query("SELECT COUNT(*) AS num FROM subscriptions"); 
    $nls = count_query("SELECT COUNT(*) AS num FROM newsletters"); 
    $mess = count_query("SELECT COUNT(*) AS num FROM messages"); 
    $temps = count_query("SELECT COUNT(*) AS num FROM templates"); 
    $title = "Home!"; 
    $content = <<<EOF 
    <h3>current stats</h3> 
    <p>$users user registered</p> 
    <p>$emails subscribers</p> 
    <p>$subs newsletter subscriptions</p> 
    <p>$nls newsletters</p> 
    <p>$mess messages</p> 
    <p>$temps templates</p> 
    EOF; 
    include 'layout.php'; ?>

the layout page:布局页面:

 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> 
    <html xmlns="http://www.w3.org/1999/xhtml" > 
        <head> 
            <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 

            <title><?php echo $title; ?> » my newsletter app</title> 
            <!-- Stylesheets --> 
            <!-- <link rel="stylesheet" href="media/style.css" type="text/css" media="all" /> --> 
        </head> 
        <body<?php if ($mini == true) { ?> class="mini"<?php } ?>> 
            <div id="header"> 
                <h1><a href="index.php">my newsletter app</a></h1> 
            </div> 
            <?php if ($nonav == false) { ?> 
            <div id="nav"> 
                <a href="messages.php"<?php if($tab == 'mess') {?>class="current"<?php } ?>>messages</a> 
                <a href="subscribers.php"<?php if($tab == 'sub') {?>class="current"<?php } ?>>subscribers</a> 
                <a href="newsletters.php"<?php if($tab == 'nl') {?>class="current"<?php } ?>>newsletters</a> 
                <a href="templates.php"<?php if($tab == 'temp') {?>class="current"<?php } ?>>templates</a> 
                <span class="right"> 
                    <a href="logout.php">log out</a> 
                </span> 
            </div> 
            <?php } ?> 
            <div id="container"> 
                <h3><?php echo $title;?></h3> 
                <?php echo $content; ?> 
            </div> 
        </body> 
    </html>

the config page:配置页面:

<?php  
    // DB Settings 
    define('DB_SERVER', 'localhost'); 
    define('DB_USER', 'abdulsme_admin'); 
    define('DB_PASSWORD', 'bypass'); 
    define('DB_NAME', 'abdulsme_newsletter'); 

    define('FROM_EMAIL', 'no_reply@ohyeahemail.com'); 
    define('FROM_NAME', 'oh yeah email!'); 


    session_start(); 
    require_once 'classes.php'; 
    $mini = false; 
    $nonav = false; 
    error_reporting(0);
    ?>

Remove all indenting from your closing EOF;删除结束 EOF 中的所有缩进; line.线。

From the PHP manual:从 PHP 手册:

It is very important to note that the line with the closing identifier must contain no other characters, except a semicolon (;).请务必注意,带有结束标识符的行不得包含除分号 (;) 之外的其他字符。 That means especially that the identifier may not be indented, and there may not be any spaces or tabs before or after the semicolon.这尤其意味着标识符不能缩进,并且分号前后不能有任何空格或制表符。

If this rule is broken and the closing identifier is not "clean", it will not be considered a closing identifier, and PHP will continue looking for one.如果这条规则被打破并且结束标识符不是“干净的”,它不会被认为是一个结束标识符,PHP 将继续寻找一个。 If a proper closing identifier is not found before the end of the current file, a parse error will result at the last line.如果在当前文件结束之前没有找到合适的结束标识符,最后一行将导致解析错误。

http://php.net/manual/en/language.types.string.php#language.types.string.syntax.heredoc http://php.net/manual/en/language.types.string.php#language.types.string.syntax.heredoc

Change:改变:

$content = <<<EOF 
<h3>current stats</h3> 
<p>$users user registered</p> 
<p>$emails subscribers</p> 
<p>$subs newsletter subscriptions</p> 
<p>$nls newsletters</p> 
<p>$mess messages</p> 
<p>$temps templates</p> 
EOF;

To:至:

$content = "
<h3>current stats</h3> 
<p>$users user registered</p> 
<p>$emails subscribers</p> 
<p>$subs newsletter subscriptions</p> 
<p>$nls newsletters</p> 
<p>$mess messages</p> 
<p>$temps templates</p> 
";

Or to:或至:

$content = <<<EOF
    <h3>current stats</h3> 
    <p>$users user registered</p> 
    <p>$emails subscribers</p> 
    <p>$subs newsletter subscriptions</p> 
    <p>$nls newsletters</p> 
    <p>$mess messages</p> 
    <p>$temps templates</p> 
EOF;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM