Jump to content

[SOLVED] Syntax error (for PHP and Wordpress experts!)


loyski

Recommended Posts

Hello PHP geeks, especially Wordpress experts!

 

I'm new to this forum. Can anyone pls help me solve this PHP error in my Wordpress blog: http://loymeetsworld.com/2008/06/18/this-blog-is-due-for-launch/

 

Here is the PHP code for the comments.php file:

 


<?php // Do not delete these lines
   if ('comments.php' == basename($_SERVER['SCRIPT_FILENAME']))
      die ('Please do not load this page directly. Thanks!');

        if (!empty($post->post_password)) { // if there's a password
            if ($_COOKIE['wp-postpass_' . COOKIEHASH] != $post->post_password) {  // and it doesn't match the cookie
            ?>
            
            <p class="nocomments">This post is password protected. Enter the password to view comments.<p>
            
            <?php
            return;
            }
        }

      /* This variable is for alternating comment background */
      $oddcomment = 'alt';
?>

<!-- You can start editing here. -->

<?php if ($comments) : ?>

  <?php

   /* Count the totals */
   $numPingBacks = 0;
   $numComments  = 0;

   /* Loop through comments to count these totals */
   foreach ($comments as $comment) {
      if (get_comment_type() != "comment") { $numPingBacks++; }
      else { $numComments++; }
   }

?>
  <?php

   /* This is a loop for printing comments */
   if ($numComments != 0) : ?>
   <h3 id="comments"><?php comments_number('No Responses', 'One Response', '% Responses' );?> to &#8220;<?php the_title(); ?>&#8221;</h3>

   <ol class="commentlist">

   <?php foreach ($comments as $comment) : ?>
   <?php if (get_comment_type() == "comment"){ ?>

      <li class="<?php if ( $comment->comment_author_email == get_the_author_email() ) echo 'authorcomment'; else echo $oddcomment; ?>" id="comment-<?php comment_ID() ?>">
      <?php if (function_exists('gravatar')) { ?><img src="<?php gravatar('X', '32', get_bloginfo('template_url')."/images/defaultgravatar.jpg"); ?>" alt="Gravatar Icon" class="gravatar" /><?php } ?>
         <cite><?php comment_author_link() ?></cite> Says:
         <br />

         <small class="commentmetadata"><span class="date"><a href="#comment-<?php comment_ID() ?>" title=""><?php comment_date('F jS, Y') ?> at <?php comment_time() ?></a></span> <span class="edit"><?php edit_comment_link('edit','',''); ?></span></small>

         <?php comment_text() ?>

         <?php if ($comment->comment_approved == '0') : ?>
         <em>Your comment is awaiting moderation.</em>
         <?php endif; ?>

      </li>

   <?php /* Changes every other comment to a different class */
      if ('alt' == $oddcomment) $oddcomment = '';
      else $oddcomment = 'alt';
   ?>

    <?php endif; endforeach; ?>

   </ol>
   <?php endif; ?>

<?php

   /* This is a loop for printing trackbacks if there are any */
   if ($numPingBacks != 0) : ?>
   <h3><?php _e($numPingBacks); ?> Trackbacks/Pingbacks</h3>
   <ol class="pingslist">
   <?php foreach ($comments as $comment) : ?>
   <?php if (get_comment_type() != "comment"){ ?>
      <li class="<?php echo $oddcomment; ?>" id="comment-<?php comment_ID() ?>"><?php comment_author_link() ?> - <span><?php comment_date('M jS, Y') ?> at <?php comment_time() ?></span></li>
   <?php /* Changes every other comment to a different class */ if ('alt' == $oddcomment) $oddcomment = ''; else $oddcomment = 'alt'; ?>
    <?php endif; endforeach; ?>
   </ol>
   <?php endif; ?>

<?php else : // this is displayed if there are no comments so far ?>

  <?php if ('open' == $post-> comment_status) : ?> 
      <!-- If comments are open, but there are no comments. -->
      <h3>No Comments Yet</h3>
      <p>You can be the first to comment! Don't be afraid.</p>

    <?php else : // comments are closed ?>
      <!-- If comments are closed. -->
      <p class="info">Sorry, comments are closed at this time.</p>

   <?php endif; ?>
<?php endif; ?>


<?php if ('open' == $post-> comment_status) : ?>

<h3 id="respond">Leave a Reply</h3>

<?php if ( get_option('comment_registration') && !$user_ID ) : ?>
<p>You must be <a href="<?php echo get_option('siteurl'); ?>/wp-login.php?redirect_to=<?php the_permalink(); ?>">logged in</a> to post a comment.</p>
<?php else : ?>

<form action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post" id="commentform" onsubmit="new Ajax.Updater({success: 'commentlist'}, '<?php bloginfo('stylesheet_directory') ?>/comments-ajax.php', {asynchronous: true, evalScripts: true, insertion: Insertion.Bottom, onComplete: function(request){complete(request)}, onFailure: function(request){failure(request)}, onLoading: function(request){loading()}, parameters: Form.serialize(this)}); return false;">

<?php if ( $user_ID ) : ?>

<p>Logged in as <a href="<?php echo get_option('siteurl'); ?>/wp-admin/profile.php"><?php echo $user_identity; ?></a>. <a href="<?php echo get_option('siteurl'); ?>/wp-login.php?action=logout" title="<?php _e('Log out of this account') ?>">Logout »</a></p>

<?php else : ?>

<p><input type="text" name="author" id="author" value="<?php echo $comment_author; ?>" size="22" tabindex="1" />
<label for="author"><small>Name <?php if ($req) _e('(required)'); ?></small></label></p>

<p><input type="text" name="email" id="email" value="<?php echo $comment_author_email; ?>" size="22" tabindex="2" />
<label for="email"><small>Mail (will not be published) <?php if ($req) _e('(required)'); ?></small></label></p>

<p><input type="text" name="url" id="url" value="<?php echo $comment_author_url; ?>" size="22" tabindex="3" />
<label for="url"><small>Website</small></label></p>

<?php endif; ?>

<p><small><strong>XHTML:</strong> You can use these tags: <code><?php echo allowed_tags(); ?></code></small></p>

<p><textarea name="comment" id="comment" cols="100%" rows="10" tabindex="4"></textarea></p>

<?php if (function_exists('show_subscription_checkbox')) { show_subscription_checkbox(); } ?>

<p><input name="submit" type="submit" id="submit" tabindex="5" value="Submit" />
<input type="hidden" name="comment_post_ID" value="<?php echo $id; ?>" />
</p>
<?php do_action('comment_form', $post->ID); ?>

</form>

<?php endif; // If registration required and not logged in ?>

<?php endif; // if you delete this the sky will fall on your head ?>


 

 

Here is the code for the single.php file:

 

<?php get_header(); ?>

   <div id="content" class="narrowcolumn">
   <a name="main"></a>

   <?php if (function_exists('wp_ozh_wsa')) { ?>
   <!-- start Who Sees Ads? plugin code -->
   <div class="adsense">
   <?php wp_ozh_wsa("468x60-top"); ?>
   </div>
   <!-- end Who Sees Ads? plugin code -->
   <?php } ?>

  <?php if (have_posts()) : while (have_posts()) : the_post(); ?>

   <?php include (TEMPLATEPATH . '/navigation.php'); ?>

      <div class="post">
         <h2 id="post-<?php the_ID(); ?>"><a href="<?php echo get_permalink() ?>" rel="bookmark" title="Permanent Link: <?php the_title(); ?>"><?php the_title(); ?></a></h2>
         <div class="postinfo"><span class="posted">Stats: <?php if (function_exists('the_views')) { ?><?php the_views(); ?>, <?php } ?><a href="#comments"><?php comments_number('0','1','%'); ?> comments</a></span><br /><span class="tags">Tags: <?php the_tags(); ?></span>
         </div>

         <div class="entry">
            <?php the_content('<p class="serif">Read the rest of this entry »</p>'); ?>

            <?php link_pages('<p><strong>Pages:</strong> ', '</p>', 'number'); ?>

<?php if (function_exists('sociable_html')) { print sociable_html(); } ?>

            <p class="postmetadata">
               <small>
                  This entry was posted by <?php the_author() ?>
                  <?php /* This is commented, because it requires a little adjusting sometimes.
                     You'll need to download this plugin, and follow the instructions:
                     http://binarybonsai.com/archives/2004/08/17/time-since-plugin/ */
                     /* $entry_datetime = abs(strtotime($post->post_date) - (60*120)); echo time_since($entry_datetime); echo ' ago'; */ ?>
                  on <?php the_time('l, F jS, Y') ?> at <?php the_time() ?>
                  and is filed under <?php the_category(', ') ?>.
                  You can follow any responses to this entry through the <?php comments_rss_link('RSS 2.0'); ?> feed.

                  <?php if (('open' == $post-> comment_status) && ('open' == $post->ping_status)) {
                     // Both Comments and Pings are open ?>
                     You can <a href="#respond">leave a response</a>, or <a href="<?php trackback_url(display); ?>">trackback</a> from your own site.

                  <?php } elseif (!('open' == $post-> comment_status) && ('open' == $post->ping_status)) {
                     // Only Pings are Open ?>
                     Responses are currently closed, but you can <a href="<?php trackback_url(display); ?> ">trackback</a> from your own site.

                  <?php } elseif (('open' == $post-> comment_status) && !('open' == $post->ping_status)) {
                     // Comments are open, Pings are not ?>
                     You can skip to the end and leave a response. Pinging is currently not allowed.

                  <?php } elseif (!('open' == $post-> comment_status) && !('open' == $post->ping_status)) {
                     // Neither Comments, nor Pings are open ?>
                     Both comments and pings are currently closed.

                  <?php } edit_post_link('Edit this entry.','',''); ?>

               </small>
            </p>

      <div class="navigation">
         <div class="alignleft"><?php previous_post('%','','yes') ?></div>
         <div class="alignright"><?php next_post('%','','yes') ?></div>
      </div>

    <?php if (function_exists('similar_posts')) { ?>
    <h3>Related Entries</h3>
      <?php similar_posts(); ?>
    <?php } ?>

         </div>
      </div>

   <?php comments_template(); ?>

   <?php endwhile; else: ?>

      <p>Sorry, no posts matched your criteria.</p>

<?php endif; ?>

   </div>

<?php get_sidebar(); ?>

<?php get_footer(); ?>

 

Any help would be greatly appreciated. I would like to get this blog up and running but this error is hindering my efforts. As a reward I'll write a post about this... ;)

Link to comment
Share on other sites

OK, think I've got it... In line ~46 that says:

<?php if (get_comment_type() == "comment"){ ?>

You open that IF block with {

but in line 68 you close it with endif;

Try replacing that { with a :

Can't see anything else...

 

EDIT: Just tested at my place, same error... so, this would be it. Be careful I think I saw more of this in your comment.php code

Link to comment
Share on other sites

  • 3 weeks later...

I need some help I can't get this syntax error resolved.. It keeps showing errors and it won't show my comments..

 

Please Help I dunno whats going on at all..

 

Here is the Error: Parse error: syntax error, unexpected T_ENDIF in /home/gymbo/public_html/lrsd/wp-content/themes/IkarusWhite/comments.php on line 34

 

 

Heres the Code:

 

--------------

 

<?php // Do not delete these lines

if ('comments.php' == basename($_SERVER['SCRIPT_FILENAME']))

die ('Please do not load this page directly. Thanks!');

if (!empty($post->post_password)) { // if there's a password

if ($_COOKIE['wp-postpass_' . COOKIEHASH] != $post->post_password) {  // and it doesn't match the cookie

?>

<h2><?php _e("This post is password protected. Enter the password to view comments."); ?></h2>

<?php

return;

}

}

$commentalt = '-alt';

$commentcount = 1; ?>

 

<div id="comments-template">

<a name="comments" id="comment"></a>

<a name="respond" id="respond"></a>

<?php if ('open' == $post->comment_status) : ?> <br />

<h4><?php comments_number('No User', '1 User', '% Users' );?> Responded In This Article</h4><br />

<div class="rss-subscribes"><?php comments_rss_link('Subscribes'); ?> To This Post Rss Feeds Or Leave A <a href="<?php trackback_url(display); ?>">Trackback</a></div>

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

<?php else: ?>

<h2>Comments For This Post Topic Was Disable By Author</h2>

<?php endif; ?>

 

<?php if ( $comments ) : ?>

<? // Begin Comments ?>

<?php foreach ($comments as $comment) : ?>

<? if ($comment->comment_type != "trackback" && $comment->comment_type != "pingback" && !ereg("<pingback />", $comment->comment_content) && !ereg("<trackback />", $comment->comment_content)) { ?>

 

<div class="comment-list<?php echo $commentalt; ?>" id="comment-<?php comment_ID() ?>">

<div class="c-left">

<div class="comment-user"><span class="aut"><?php comment_author_link(); ?></span> Said in <?php comment_date('F jS, Y') ?> <a href="#comment-<?php comment_ID() ?>">@<?php comment_time() ?></a>  <?php edit_comment_link('edit','',''); ?></div>

<?php endif; ?>

 

<?php if ($comment->comment_approved == '0') : ?>

<div class="under-mod">Your Comment Is Under Moderation </div>

<?php else: ?>

<div class="c-right"><?php

  echo get_avatar( $id_or_email, $size = '50', $default = '<?php bloginfo('stylesheet_directory'); ?>/images/mygif.gif' );

  ?>

</div>

</div>

 

<p><?php comment_text(); ?></p>

<?php endif; ?>

</div>

 

<?php

($commentalt == "-alt")?$commentalt="":$commentalt="-alt";

$commentcount++;

?>

<? } ?>

<?php endforeach; /* end for each comment */ ?>

 

<? // Begin Trackbacks ?>

<?php foreach ($comments as $comment) : ?>

<? if ($comment->comment_type == "trackback" || $comment->comment_type == "pingback" || ereg("<pingback />", $comment->comment_content) || ereg("<trackback />", $comment->comment_content)) { ?>

 

<? if (!$runonce) { $runonce = true; ?>

 

<h5>Pingback And Trackback To This Post</h5>

<div class="rss-subscribes"><a href="<?php the_permalink(); ?>">Permalink</a> To This Post</div>

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

 

<? } ?>

 

<div class="pingback<?php echo $commentalt; ?>" id="comment-<?php comment_ID() ?>">

<span class="aut"><?php comment_ID() ?>. </span>

<?php comment_author_link(); ?></div>

 

 

<?php

($commentalt == "-alt")?$commentalt="":$commentalt="-alt";

$commentcount++;

?>

<? } ?>

<?php endforeach; /* end for each comment */ ?>

 

<? if ($runonce) { ?>

<? } ?>

<? // End Trackbacks ?>

 

<?php endif; ?>

 

<? // End Comments ?>

 

<?php if ('open' == $post->comment_status) : ?>

 

<?php if (get_option('comment_registration') && !$user_ID) : ?>

 

<h2>Sorry the comment area are closed</h2>

 

<?php else : ?>

 

 

<h5>Leave Your Comment Below</h5>

<div class="user-stats"><?php if ($user_ID) : ?>Login as <a href="<?php echo get_option('siteurl'); ?>/wp-admin/profile.php"><?php echo $user_identity; ?></a>    <?php endif; ?><a href="<?php echo get_option('siteurl'); ?>">Back to homepage</a><?php if ($user_ID) : ?>    <a href="<?php echo get_option('siteurl'); ?>/wp-login.php?action=logout">logout</a><?php endif; ?></div>

 

<form action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post" id="comment-form">

 

<?php if (!$user_ID) : ?>

<label>Username: <span>(*required)</span></label>

<p><input name="author" type="text" class="input-box" value="<?php echo $comment_author; ?>"/></p>

<label>Email Address: <span>(*required)</span></label>

<p><input name="email" type="text" class="input-box" value="<?php echo $comment_author_email; ?>"/></p>

<label>Website: <span>(*optional)</span></label>

<p><input name="url" type="text" class="input-box" value="<?php echo $comment_author_url; ?>"/></p>

<?php endif; ?>

 

 

<label>Leave comments here</label>

<p><textarea name="comment" cols="50%" rows="8" class="input-area" id="comments"></textarea></p>

<p><input name="submit" type="submit" class="post-the-comment" value="Post My Comment" /><input type="hidden" name="comment_post_ID" value="<?php echo $id; ?>" /></p>

<p><strong>Please Note:</strong> moderation maybe under moderation so there is no need to resubmit your comments. Feel free to <?php comments_rss_link('subscribes'); ?> to this post comment rss feeds for future updates</p>

</form>

 

<?php endif; // If registration required and not logged in ?>

 

<?php endif; // if you delete this the sky will fall on your head ?>

 

</div>

 

--------------------

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.