解析错误:$ end

时间:2014-04-23 15:44:13

标签: php syntax-error

所以我收到了错误:

  

解析错误:语法错误,我的代码中第97行的C:\ xampp \ htdocs \ CWoW \ add.php中的意外$结尾。

    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="utf8">
    <link rel="stylesheet" href="main.css">
    <link rel="stylesheet" href="default.css">
    <link rel="stylesheet" href="cms.css">
    <title>ACP</title>
    </head>
    <body>
    <?php
    if(isset($_POST['add']))
    {
    $dbhost = 'localhost:3306';
    $dbuser = 'root';
    $dbpass = '';
    $mysqli = new mysqli('localhost','root','','meh') or die("Error " . mysqli_error($mysqli));


    if(empty($_POST['title'])) {
    echo 'The title must not be empty!<br/>';
    } else if(empty($_POST['message'])) {
    echo 'The message field must not be empty!<br/>';
    } else if(empty($_POST['author'])) {
    echo 'A poster name is required!<br/>';
    } else {
    if(! get_magic_quotes_gpc() )
    {
    $title = addslashes ($_POST['title']);
    $message = addslashes ($_POST['message']);
    $author = addslashes ($_POST['author']);
    }
    else
    {
    $title = $_POST['title'];
    $message = $_POST['message'];
    $author = $_POST['author'];
    }

    if ($query = $mysqli->query("INSERT INTO etl_articles (title, message, author) VALUES ('{$title}', '{$message}', '{$author}');")) {
    echo "The post has successfully been added! <a href='add.php'>Click Here</a> to go back.";

    } else {
    echo 'Failed to add the post!';
    $query->close;
    }
    }
    }
    else
    {
    ?>

    <div id="logo_div">
            <a id="logo_anch" href="#" title="Project Hysteria">Project Hysteria</a>
        </div>
    <ul id="top_menu">
                                <li><a href="index.php" direct="0">Home</a></li>
                        </ul>
    <div id="main">
            <aside id="right">
                <div id="main_sep"></div>
                <div id="content_ajax">
                <form method="post" action="<?php $_PHP_SELF ?>" class="custom2">
<article>
    <div class="top"><input name="title" type="text" placeholder="» Title" /></div>
    <section class="body">

        <div class="clear"></div>

        <div class="news_bottom">

<textarea name="message" placeholder="» Message"></textarea><br><br>    
<select name="author">
    <option value="Admin">Admin</option>
    <option value="Moderator">Global Moderator</option>
    <option value="Developer">Developer</option>
    </select><br><br>           
<input name="add" type="submit" value="Submit News" />
</div>

        <div class="comments" id="comments_17"></div>
    </section>
</article>

    </div>
            </aside>
            <div class="clear"></div>
        </div>
        </form>
                <footer>
    <a href="http://raxezdev.com/fusioncms" id="logo" target="_blank"></a>
    <p>© Copyright 2013 Caustic WoW</p>
            <p id="design"> <a target="_new" href=""></a></p>
    </footer>
    </section>
    </body>
    </html>

我似乎无法真正找到问题所在。 如果你们中的任何一个人能帮助我,那就太好了。

1 个答案:

答案 0 :(得分:-1)

您的代码中存在语法错误:在{语句后有一个左括号else,但缺少结束}

<强>替换

else
{
?>

else;
?>

else{}
?>