Parse error

Hello:

I hope that I am posting this in the correct forum. I am currently working on integrating a wordpress blog into a website. I am very new to PHP and slogging my way through but ran into a problem almost immediately. I am getting two error messages. I know that they are most likely something as simple as a semicolon that is not needed, I have no idea how to fix them. Hopefully someone here can help :slight_smile: My code is:

[php]<?php
get_header(); ?>

<?php while ( have_posts() ) : the_post(); ?>
				<?php get_template_part( 'content', get_post_format() ); ?>

			<?php endwhile; ?>

			<?php twentyeleven_content_nav( 'nav-below' ); ?>

		<?php else : ?>

			<article id="post-0" class="post no-results not-found">
				<header class="entry-header">
					<h1 class="entry-title"><?php _e( 'Nothing Found', 'twentyeleven' ); ?></h1>
				</header><!-- .entry-header -->

				<div class="entry-content">
					<p><?php _e( 'Apologies, but no results were found for the requested archive. Perhaps searching will help find a related post.', 'twentyeleven' ); ?></p>
					<?php get_search_form(); ?>
				</div><!-- .entry-content -->
			</article><!-- #post-0 -->

		<?php endif; ?>
                    </div>
                  
                </div>

              <div class="row">
<?php get_footer(); ?>[/php]

My errors are on lines 12 and 25.

Any help is greatly appreciated.

Cheers,
Sarah

First of all you must be using some kind of php framework? I can’t tell with the small amount of code given and speaking of code I couldn’t tell what is line 12 and line 25? Which brings me to my second part, the code given is spaghetti code, by this I mean you have <?php ?> intermingle throughout the script. Which means it’s going to make it very confusing for you to learn php and makes be believe you are using some kind of framework.

While I haven’t really worked with Wordpress, I was under the assumption that Wordpress had it’s own blogging scheme (from what little I have fooled around with Wordpress). So why are you messing around with the code?

As I said, I am integrating the blog INTO a website…as in embedding it into a page on my website, as opposed to it standing on its own. That is why I am messing with the code. Is that relevant to my question of a parse error?

Apologies for not clarifying what lines I was specifically talking about. I have never been to this forum and I suppose I thought that the php code button would put the code into a format with each line numbered, as does Dreamweaver and for that matter, the simple editor my web host has. I will be sure to use the preview post button more throughly in the future when I am here. I am asking about the following snippets of code:

[php]<?php else : ?>[/php]

And [php]<?php endif; ?>[/php]

I guess I didn’t realize this was spaghetti coded together, as I am a newbie, so if this simply isn’t a straightforward answer and more information is needed, I can only direct you to the tutorial I am working from:

http://www.burnseo.com/blog/2009/10/23/integrate-wordpress-into-existing-website-tutorial/

If it helps clarify more, my website is http://www.squamriverstudios.com. To help further, I intend to put my posts inside the framework that already exists on my site. For example, if you were to go to http://www.squamriverstudios.com/design.html you will see a page that says .01Design with a quote beneath it. I will be replicating the framework of that page and instead of .01 Design, the blog page will look just like that and say .01 Blog and under where the quote is now, my blog posts will reside. Does that make sense?

While I am not expecting to learn PHP from beginning to end with this process, I feel sure that I will learn quite a bit. If you cannot help, I appreciate the time that you took to read this and my previous post.

Best,
Sarah

P.S. For some reason I am getting an error that says that posting web addresses with the url button on this forum is not available at this time. Apologies for that.

Sarah,
I have just placed your code from the first post into my editor to check it out for you,
I immediately see you are using an ‘else’ clause with no ‘if’ - this is not allowed.

The second post you made regarding ‘else:’ and ‘endif’
Let me explain.

These are part of a looping statement and are usually - though not always - coded like so:
[php]if(something here evaluates to true or false) {
// do something if true
}
else {
// do something else if false.
}[/php]

Alternately they can be coded like so:
[php]if(blah blah) :
// do something if true
else:
// do something else if false.
endif;[/php]

Hope that sheds some light onto it.
Red :wink:

This might also clear it up a little bit more?

[php]<?php $foo = false ?>

<?php if ($foo == true): echo "execute if true
";?>

Hello

<?php else: echo "execute if false
"; ?>

GoodBye

<?php endif; ?>[/php]

P.S. I just like to say I’m sorry, but like I said I don’t know WordPress to well and I’m kind of surprise isn’t an add-on/plugin already out there for something like this?

Thank you both gentlemen- both answers were helpful and I understand a bit now. I will undoubtably will be back for more help LOL but for now, I’m set!

S

Sponsor our Newsletter | Privacy Policy | Terms of Service