19 posts
    Has been part of the Envato Community for over 4 years
Jonathan_Vivid says

I’ve been searching for my syntax error, but because I’m new at this, I seriously cannot find it. I’m following video tutorials, and my code has to be wrong somewhere, because I’m getting this message:

Parse error: syntax error, unexpected ‘(’, expecting ’:’ in C:\xampp\htdocs\wordpress\wp-content\themes\runner\index.php on line 28

I feel like an idiot because I can’t seem to find it. However, whenever I take out the else statement, the code works fine. I just can’t find how to fix it. Anyone think they can take three seconds and make me feel like a fool? : P

<!DOCTYPE html public "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/strict.dtd">

<html xmlns ="http://www.w3.org/1999/xhtml" <?php language_attributes();?>>
<head>
      <meta http-equiv="Content Type" content='<?php bloginfo('html_type');?> charset='<?php bloginfo('charset');?>/>
      <title><?php bloginfo('name');?></title>
      <link rel="stylesheet" href='<?php bloginfo('stylesheet_url');?>'>
</head>
<body>
    <div id="wrap">
    <!--Begin Header-->
    <div id="header">
    <h1><a href='<?php echo get_option('home');?>/'><?php bloginfo(name);?></h1>
    <div id="tagline"><?php bloginfo('description');?></div>
    </div>
    <!--End Header-->

    <!--Begin Content-->
    <?php if(have_posts()) :?>
        <?php while(have_posts()) : the_post()?>
        <div class="post_snippet">
        <h2><a href="<?php the_permalink(); ?>" title="Permanent link to <?php                 the_title_attribute();?>"> <?php the_title();?></a></h2>
        <?php the_content('Continue Reading...');?>
        </div>

        <?php endwhile;?>
        <p><?php previous_posts_link('Previous Entries');?><?php next_posts_link('Older Entries');?></p>
        <?php else() :?>
        <h2>Sorry, but we could not find any posts!</h2>
        <?php endif;?>

    <!--End Content-->

    <!--Begin Footer-->
    <div id="footer">
    <p><?php bloginfo('name');?> is proudly powered by <a href="http://wordpress.org">Wordpress</a> |  <a href='<?php bloginfo('rss2_url');?>'>Full RSS Posts and <a href='<?php bloginfo('rss2_url');?>'>Comments. </p>
    </div>
    <!--End Footer-->

    </div>
</body>


I just wish the video tutorials came with the text in a file or something. It’s so hard to see exactly what he types. :P

Thanks so much.

~Jonathan

Edit: Of course, as soon as I decide to post for help, I find my error. Delete this thread, sorry for the trouble!

443 posts
    Has been part of the Envato Community for over 4 years Has sold $1,000+ on Envato Market Has collected 10+ items on Envato Market Sells items exclusively on Envato Market
+1 more
SplitV says

The line….

<?php else() :?>

Should be

<?php else:?>

Right before the line

“Sorry, but we could not find any posts!”

444 posts
    Has been part of the Envato Community for over 4 years Has collected 1+ items on Envato Market Sells items exclusively on Envato Market Located in United Kingdom
TahaH-Studio says

Can you re insert the code above in a ‘pre’ tag. I cant tell the lines number :D .

2541 posts
    Has referred 10+ members Has sold $100+ on Envato Market Has collected 50+ items on Envato Market Located in United States
+9 more
CreatingDrew says

Fixed the formatting, to the OP, no worries on deleting the thread. Chances are someone may find this helpful sometime during a search on the forums :)

3135 posts
    Has been part of the Envato Community for over 5 years Has sold $1,000+ on Envato Market Has been a beta tester for an Envato feature Has collected 500+ items on Envato Market
+4 more
Daniel_R says
Fixed the formatting, to the OP, no worries on deleting the thread. Chances are someone may find this helpful sometime during a search on the forums :)

great work as usual, Drew

629 posts
    Has been part of the Envato Community for over 4 years Has referred 10+ members Has collected 10+ items on Envato Market Sells items exclusively on Envato Market
+2 more
VagrantRadio says

If you’re using an editor with line numbers, the error tells you where the problem is and what to fix.

28  <?php else() :?>
unexpected ‘(’, expecting ’:’

Means that shouldn’t be there.

by
by
by
by
by
by