954,568 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Pesky Parse error... NUTTS!

It's probably OBVIOUS to most of you (I'm a self-taught PHP novice) but I can't, for the LIFE of me, figure out what's wrong with this code!

I'm getting a parse error that points to the open curly quotes (in red) in the first line of this code: "...parse error, unexpected '{' in /blah/blah/index.php on line [first line in code below]."

I think I must be blind... can anybody see what's wrong here?

<?php if (mosCountModules('user3') || (mosCountModules('user4') || (mosCountModules('user5')) { ?>
            <div id="pod"><!-- Start pod-->
				<?php if (mosCountModules('user3')) { ?>
                    <div id="podcol1" style="width:<?php echo $podmodwidth ?>;"><?php mosLoadModules ('user3',-2); ?></div><?php } ?>
				<?php if (mosCountModules('user4')) { ?>
                    <div id="podcol2" style="width:<?php echo $podmodwidth ?>;"><?php mosLoadModules ('user4',-2); ?></div><?php } ?>
                <?php if (mosCountModules('user5')) { ?>
                    <div id="podcol3" style="width:<?php echo $podmodwidth ?>;"><?php mosLoadModules ('user5',-2); ?></div><?php } ?>
            </div><!-- End pod-->
			<?php } ?>


Thanks for ANY help/suggestion!

GEOHAM
Newbie Poster
3 posts since Apr 2008
Reputation Points: 10
Solved Threads: 0
 

I think it's sorted.....

if(mosCountModules('user3') || (mosCountModules('user4')) || (mosCountModules('user5')) ) { 
?>
            <div id="pod"><!-- Start pod-->
				<?php if (mosCountModules('user3')) { ?>
                    <div id="podcol1" style="width:<?php echo $podmodwidth ?>;"><?php mosLoadModules ('user3',-2); ?></div><?php } ?>
				<?php if (mosCountModules('user4')) { ?>
                    <div id="podcol2" style="width:<?php echo $podmodwidth ?>;"><?php mosLoadModules ('user4',-2); ?></div><?php } ?>
                <?php if (mosCountModules('user5')) { ?>
                    <div id="podcol3" style="width:<?php echo $podmodwidth ?>;"><?php mosLoadModules ('user5',-2); ?></div><?php } ?>
            </div><!-- End pod-->
			<?php } ?>


If this has helped you please add to my reputation.

thanks!

Regards,
Alex

phper
Posting Whiz in Training
213 posts since Nov 2006
Reputation Points: 22
Solved Threads: 19
 

putting html in between the php tags makes it very confusing to me.

here is some code I made see if it solved the problem:

<?php

if ((mosCountModules('user3')) || (mosCountModules('user4')) || (mosCountModules('user5'))) {
	echo '<div id="pod"><!-- Start Pod -->';
	if (mosCountModules('user3')) {
		echo '<div id="podcol1" style="width:' . $podmodwidth . '">' . mosLoadModules('user3',-2) . '</div>';
	}
	if (mosCountModules('user4')) {
		echo '<div id="podcol2" style="width:' . $podmodwidth . '">' . mosLoadModules('user4',-2) . '</div>';
	}
	if (mosCountModules('user5')) {
		echo '<div id="podcol3" style="width:' . $podmodwidth . '">' . mosLoadModules('user5',-2) . '</div>';
	}
	echo '</div><!- End pod -->';
}

?>
kkeith29
Nearly a Posting Virtuoso
1,357 posts since Jun 2007
Reputation Points: 235
Solved Threads: 194
 

I find HTML between tags quite confusing aswell.

GEOHAM - have you set out your code as it is on here? You might want to space it out a little bit clearer and possibly comment the code so you know what it is if you ever have to come back to it in the future.

phper
Posting Whiz in Training
213 posts since Nov 2006
Reputation Points: 22
Solved Threads: 19
 

I think it's sorted.....

if(mosCountModules('user3') || (mosCountModules('user4')) || (mosCountModules('user5')) ) { 
?>
            <div id="pod"><!-- Start pod-->
				<?php if (mosCountModules('user3')) { ?>
                    <div id="podcol1" style="width:<?php echo $podmodwidth ?>;"><?php mosLoadModules ('user3',-2); ?></div><?php } ?>
				<?php if (mosCountModules('user4')) { ?>
                    <div id="podcol2" style="width:<?php echo $podmodwidth ?>;"><?php mosLoadModules ('user4',-2); ?></div><?php } ?>
                <?php if (mosCountModules('user5')) { ?>
                    <div id="podcol3" style="width:<?php echo $podmodwidth ?>;"><?php mosLoadModules ('user5',-2); ?></div><?php } ?>
            </div><!-- End pod-->
			<?php } ?>

AWESOME!!!! Thanks SO MUCH, Alex! :) Daniweb Rocks! (See eeaa.us for the results of your labors.)

GEOHAM
Newbie Poster
3 posts since Apr 2008
Reputation Points: 10
Solved Threads: 0
 

To kkeith29: Thanks!... your code worked (I no longer got the parse error) but it broke my styling(?).

Instead of floating each "podcol," they were stacked... which negates the code (which is wholly there to control the column width based on how many modules are loaded (see eeaa.us). Thanks VERY much for your fix... I will take your suggestion to NOT nest PHP inside tags to heart!

GEOHAM
Newbie Poster
3 posts since Apr 2008
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You