2014-04-23 45 views
0

所以我得到一個錯誤:我好像

Parse error: syntax error, unexpected $end in C:\xampp\htdocs\CWoW\add.php on line 97 in my code.

<!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> 

不能真正發現問題。 如果你們中的任何人都可以幫助我,那會很棒。

+2

你缺少你最後else語句結束的括號。 –

回答

-1

您的代碼中存在語法錯誤:在else聲明後有一個開頭大括號{,但結尾}缺失。

更換

else 
{ 
?> 

else; 
?> 

else{} 
?> 
相關問題