• Resolved joebrooksie

    (@joebrooksie)


    Here is my code for get_posts…

    <?php global $post;
        $batch1= get_posts(‘numberposts=2');
        $batch2= get_posts(‘numberposts=3&offset=1');
        $batch3= get_posts(‘numberposts=5&offset=4&order=DESC&orderby=post_date’);
    ?>

    And it’s spitting out this error:

    Parse error: syntax error, unexpected ‘=’ in /home/.pottier/joebrooks/joe-brooks.com/wp13/wp-content/themes/sweetnursingtheme/home.php on line 31

    Any ideas what I’m doing wrong? Line 31 is:

    $batch1= get_posts(‘numberposts=2');

Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter joebrooksie

    (@joebrooksie)

    Full File code:

    <?php get_header(); ?>
    		<?php include (TEMPLATEPATH . "/sidebarleft.php"); ?>
    <div id="content">
    	<div id='top_border_container'>
    		<p><img src="<?php bloginfo('template_directory') ?>/images/border_top.gif" width="768" height="43" /></p>
    	</div>
    	<div id='body_container_left'>
    	<div id='body_container_right'>
    	<div id='body_container_center'>
    	<div id="container_header">
    		<div id="container_header_menu">
    						<div id="container_header_rss">
    								<a href="<?php bloginfo('rss2_url'); ?>"><img src="<?php bloginfo('template_directory') ?>/images/rssicon.jpg" width="16" height="16" align="absmiddle" /> Subscribe to the Sweet Nursing Blog</a>
    						</div>
    						<div id="container_header_search">
    								<?php include (TEMPLATEPATH . '/searchform.php'); ?>
    						</div>
    						<div class="clear"></div>
    				</div>
    		</div>
    	<div class="main_content_container">
    	<div class="main_content_container_left">
    	<div class="main_content_container_left_header">
    		<p>News And Views From Sweet Nursing</p>
    	</div>
    
    	<?php if (have_posts()) : ?>
    					<?php
        global $post;
        $batch1= get_posts(‘numberposts=2');
        $batch2= get_posts(‘numberposts=3&offset=1');
        $batch3= get_posts(‘numberposts=5&offset=4&order=DESC&orderby=post_date’);
    ?>
    
    		<?php foreach($batch1 as $post) :
    					setup_postdata($post);	?>
    					<div class="post" id="post-<?php the_ID(); ?>">
    						<h2 class="posttitle"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h2>
    						<div class="entry">
    							<?php the_content('<span>Read on &raquo;</span>'); ?>
    						</div>
    						<div class="postmeta">Posted in <?php the_category(', ') ?> | <?php edit_post_link('Edit', '', ' | '); ?>  <?php comments_popup_link('No Comments', 'Comment (1)', 'Comments (%)'); ?></div>
    					</div>
    				<?php endforeach; ?>
    
    <?php foreach($batch2 as $post) :
    					setup_postdata($post);	?>
    					<div class="post" id="post-<?php the_ID(); ?>">
    						<h2 class="posttitle"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h2>
    						<div class="entry">
    							<?php the_excerpt('<span>Read on &raquo;</span>'); ?>
    						</div>
    						<div class="postmeta">Posted in <?php the_category(', ') ?> | <?php edit_post_link('Edit', '', ' | '); ?>  <?php comments_popup_link('No Comments', 'Comment (1)', 'Comments (%)'); ?></div>
    					</div>
    				<?php endforeach; ?>
    <?php foreach($batch3 as $post) :
    					setup_postdata($post);	?>
    					<strong><?php the_time('F jS, Y') ?></strong><br />
    					<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a>
    					<br /><br />
    				<?php endforeach; ?>
    
    				<div class="navigation">
    					<div class="alignleft"><?php next_posts_link('&laquo; Previous Entries') ?></div>
    					<div class="alignright"><?php previous_posts_link('Next Entries &raquo;') ?></div>
    				</div>
    
    		<?php endwhile; ?>
    
    	<?php else : ?>
    
    		<h2>Not Found</h2>
    		<p>Sorry, but you are looking for something that isn't here.</p>
    		<?php include (TEMPLATEPATH . "/searchform.php"); ?>
    
    	<?php endif; ?>
    	</div>
    
    <?php get_sidebar(); ?>
    
    <?php get_footer(); ?>

    Check the quotes. Make sure they are simple or double quotes, and not those ones automatically modified by word processors (like Word).

    Check the quotes. Make sure they are simple or double quotes, and not those ones automatically modified by word processors (like Word).

    Yes, you have fancy quotes in your code (a big no-no). Bad fancy quote (‘):

    $batch1= get_posts(‘numberposts=2');

    Fancy quote replaced with a regular quote (‘):

    $batch1= get_posts('numberposts=2');

    Thread Starter joebrooksie

    (@joebrooksie)

    Great thanks… now that I have that fixed another syntax error came up..

    Parse error: syntax error, unexpected T_ENDWHILE in /home/.pottier/joebrooks/joe-brooks.com/wp13/wp-content/themes/sweetnursingtheme/home.php on line 71

    Is there any effects that might happen if I remove “<?php endwhile; ?>” from the code?

    Moderator Samuel Wood (Otto)

    (@otto42)

    www.remarpro.com Admin

    Considering you don’t have a “while”, then I’d say you don’t need the “endwhile”.

    Thread Starter joebrooksie

    (@joebrooksie)

    That’s what I thought ??

    *flashes my php newbie card*

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘PHP syntax error?’ is closed to new replies.