Warrior Forum - The #1 Digital Marketing Forum & Marketplace

Warrior Forum - The #1 Digital Marketing Forum & Marketplace (https://www.warriorforum.com/)
-   Programming (https://www.warriorforum.com/programming/)
-   -   Getting Syntax Error In this Code of 18 Lines (php) (https://www.warriorforum.com/programming/198477-getting-syntax-error-code-18-lines-php.html)

howudoin 5th April 2010 11:53 PM

Getting Syntax Error In this Code of 18 Lines (php)
 
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

Shounak Gupte 5th April 2010 11:58 PM

Re: Getting Syntax Error In this Code of 18 Lines (php)
 
what is the exact error you are getting?

imarketstuff 6th April 2010 12:09 AM

Re: Getting Syntax Error In this Code of 18 Lines (php)
 
you have (2) php declarations:

Code:

<?php
remove the one on line 18 ;)

howudoin 6th April 2010 12:29 AM

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

Originally Posted by imarketstuff (Post 1954811)
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

howudoin 6th April 2010 12:45 AM

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

what is the exact error you are getting?
I get the following Error:

Parse error: parse error, unexpected '}' in 2.php on line 18

Luke Graham 6th April 2010 01:16 AM

Re: Getting Syntax Error In this Code of 18 Lines (php)
 
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>

Shounak Gupte 6th April 2010 01:19 AM

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

Originally Posted by Luke Graham (Post 1954960)
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!

imarketstuff 6th April 2010 09:22 AM

Re: Getting Syntax Error In this Code of 18 Lines (php)
 
oh i was totally off-base with my answer, apologies!
my excuse, it was late in the night :)


All times are GMT -6. The time now is 02:49 AM.