Hi for some reason i keep getting a parse error when i try to load my view could someone tell me why it says unexpected end to file on line 20

<section id="login-landing" class="block block-gray">
    <div class="container">
        <div class="card card-container wow zoomInUp animated">
            <a href="<?php echo base_url()?>">
                <img id="profile-img" class="profile-img-card" src="<?php echo base_url();?>assets/img/site/main.png"
                class="img-responsive">
            </a>
            <p id="profile-name" class="profile-name-card">Administrator Login</p>
            <?php if($error == 1){ ?>
                <p>The username and password did not match!</p>
            <? } ?>
            <form action="<?php echo base_url()?>users/login" method="post" class="form-signin">
                <input type="text" id="username" class="form-control" placeholder="Username" autofocus>
                <input type="password" id="password" class="form-control" placeholder="Password">
                <input type="submit" class="btn btn-lg btn-primary btn-block btn-signin" value="Sign In"></button>
            </form><!-- /form -->
            <a href="#" class="forgot-password"> Forgot your password</a>
        </div><!-- /card-container -->
    </div><!-- /container -->
</section>

on line 11, u miss the <?php ?>

When i add the <?php on line 11 it shows the error on page load not on execution of the form?

@Lau_1 means that instead of <? } ?>, it should be <?php } ?>

Try the following change:

<?php if($error == 1){
    echo "<p>The username and password did not match!</p>";
} ?>

and replace lines 9 to 11 with it. HTML is always executed on the page, and you had the HTML outside the PHP so it was always written. This change will make it so that HTML will only be written if the $error == 1 Please let us know if there are more problems.

Here is the code that I found working after modify from yours:

<?php
function base_url(){
    return "www.google.com/";
}
try {
    ?>
    <section id="login-landing" class="block block-gray">
        <div class="container">
            <div class="card card-container wow zoomInUp animated">
                <a href="<?php echo base_url(); ?>">
                    <img id="profile-img" class="profile-img-card" src="<?php echo base_url(); ?>assets/img/site/main.png" class="img-responsive"/>
                </a>
                <p id="profile-name" class="profile-name-card">Administrator Login</p>
                <?php if ($error == 1) { ?>
                    <p>The username and password did not match!</p>
                <?php } ?>
                <form action="<?php echo base_url() ?>users/login" method="post" class="form-signin">
                    <input type="text" id="username" class="form-control" placeholder="Username" autofocus>
                    <input type="password" id="password" class="form-control" placeholder="Password">
                    <input type="submit" class="btn btn-lg btn-primary btn-block btn-signin" value="Sign In"></button>
                </form><!-- /form -->
                <a href="#" class="forgot-password"> Forgot your password</a>
            </div><!-- /card-container -->
        </div><!-- /container -->
    </section>
    <?php
} catch (Exception $e) {
    echo 'Caught exception: ', $e->getMessage(), "\n";
}
?>

Modify accordingly with comparism with yoru code.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.