Welcome Guest, Not a member yet? Register   Sign In
Message: syntax error, unexpected end of file
#1

Hi Friends,

Good Day!

I would like to ask help from you,

I have encounter this error.

Quote:An uncaught Exception was encountered

Type: ParseError

Message: syntax error, unexpected end of file

Filename: D:\xampp\htdocs\webdev\automation\application\views\posts\view.php

Line Number: 46

Backtrace:

File: D:\xampp\htdocs\webdev\automation\application\controllers\Comments.php
Line: 17
Function: view

File: D:\xampp\htdocs\webdev\automation\index.php
Line: 315
Function: require_once

Please see below whole page code,




Quote:
<h2> <?php echo $post['title']; ?> </h2>  
<small class="post-date">Posted on: <?php echo $post['created_at']; ?> <?php// echo $post['posts']; ?> </small><br>
<img  src="<?php echo site_url();?>assets/images/posts/<?php echo $post['post_image']; ?>">
<br><br>
<div class="post-body">
   <?php echo $post['body']; ?>    
</div>
<hr>

<?php echo form_open('posts/delete/'.$post['id']); ?>
<a class="btn btn-primary" href="edit/<?php echo $post['slug']; ?>">Edit</a>
<input type="submit" value="Delete" class="btn btn-danger">      
</form>

<hr>
<h3>Comments</h3>
<?php if($comments): ?>
<?php foreach($comments as $comment): ?>
<div class="well">
<h5><?php echo $comment['body']; ?> [by <strong><?php echo $comment['name'];
?> </strong>] </h5>
</div>
<?php endforeach; ?>
<?php else: ?>
<p>No Comments to Display </p>
<hr>

<h3>Add Comments</h3>
<?php echo validation_errors(); ?>
<?php echo form_open('comments/create/'.$post['id']); ?>
   <div class="form-group">
   <label>Name:</label>
   <input type="text" name="name" class="form-control">
    </div>
    <div class="form-group">
   <label>Email:</label>
   <input type="text" name="email" class="form-control">
    </div>
    <div class="form-group">
   <label>Body:</label>
   <textarea type="textarea" name="body" class="form-control"></textarea>
    </div>
    <input type="hidden" name="slug" value="<?php echo $post['slug']; ?>">
    <button class="btn btn-primary" type="submit">Submit</button>
</form>

Syntax error been show up after adding this code below

Quote:<hr>
<h3>Comments</h3>
<?php if($comments): ?>
<?php foreach($comments as $comment): ?>
<div class="well">
<h5><?php echo $comment['body']; ?> [by <strong><?php echo $comment['name'];
?> </strong>] </h5>
</div>
<?php endforeach; ?>
<?php else: ?>
<p>No Comments to Display </p>
<hr>
Reply
#2

Your missing the closing php on the if statement ?>
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply




Theme © iAndrew 2016 - Forum software by © MyBB