Question

So I'm getting an error:

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>

I can't seem to find the problem really. If any of you guys can help me that would be great.

Was it helpful?

Solution

You have a syntax error in your code : there is an opening brace { after else statement but the closing } is missing.

Replace

else
{
?>

with

else;
?>

or

else{}
?>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top