Getting Syntax Error In this Code of 18 Lines (php)

7 replies
Here's the code:

------------------------------------------
<?php if (is_category()) {
$this_category = get_category($cat);
if (get_category_children($this_category->cat_ID) != "") {
echo "<ul>";
wp_list_categories('orderby=id&depth=1&show_count= 0&title_li=
&use_desc_for_title=1&child_of='.$this_category->cat_ID);
echo "</ul>";
}
}

else { ?>
<ul>
<?php $recent = new WP_Query("cat=1&showposts=3"); while($recent->have_posts()) : $recent->the_post();?>
<li><a href="<?php the_permalink();?>"><?php the_title(); ?></a></li>

</ul>
<?php
} ?>
------------------------------------------

I'm unable to find as to where exactly is the error?:rolleyes:

Can anybody help?

Thanks in advance
Bhupinder
#code #error #lines #php #syntax
  • Profile picture of the author Shounak Gupte
    what is the exact error you are getting?
    Signature
    Looking for a quality but affordable graphic designer to partner with. To express your interest PM me with some samples.
    {{ DiscussionBoard.errors[1954787].message }}
  • Profile picture of the author imarketstuff
    you have (2) php declarations:

    Code:
    <?php
    remove the one on line 18
    Signature
    I MARKET STUFF

    {{ DiscussionBoard.errors[1954811].message }}
    • Profile picture of the author howudoin
      Originally Posted by imarketstuff View Post

      you have (2) php declarations:

      Code:
      <?php
      remove the one on line 18
      Thanks for the answer but I'm unable to guess what You're pointing at!

      Can you please type the complete code (With correction), so that I may get a better handle.

      Thanks
      Bhupinder
      {{ DiscussionBoard.errors[1954853].message }}
  • Profile picture of the author howudoin
    what is the exact error you are getting?
    I get the following Error:

    Parse error: parse error, unexpected '}' in 2.php on line 18
    {{ DiscussionBoard.errors[1954882].message }}
    • Profile picture of the author Luke Graham
      Bhupinder,

      You arent ending your while loop.

      <ul>
      <?php $recent = new WP_Query("cat=1&showposts=3"); while($recent->have_posts()) : $recent->the_post();?>
      <li><a href="<?php the_permalink();?>"><?php the_title(); ?></a></li>
      <?php endwhile; ?>
      </ul>
      Signature
      Best Ways To Make Money Online

      Eight bytes walk into a bar. The bartender asks, “Can I get you anything?”
      “Yeah,” reply the bytes. “Make us a double.”
      {{ DiscussionBoard.errors[1954960].message }}
      • Profile picture of the author Shounak Gupte
        Originally Posted by Luke Graham View Post

        Bhupinder,

        You arent ending your while loop.

        <ul>
        <?php = new WP_Query("cat=1&showposts=3"); while(()) : ();?>
        <li><a href="<?php the_permalink();?>"><?php the_title(); ?></a></li>
        <?php endwhile; ?>
        </ul>
        this should fix it!
        Signature
        Looking for a quality but affordable graphic designer to partner with. To express your interest PM me with some samples.
        {{ DiscussionBoard.errors[1954974].message }}
  • Profile picture of the author imarketstuff
    oh i was totally off-base with my answer, apologies!
    my excuse, it was late in the night
    Signature
    I MARKET STUFF

    {{ DiscussionBoard.errors[1956376].message }}

Trending Topics