bruckerrlb Posted September 21, 2009 Share Posted September 21, 2009 Hello, I am trying to use php to find out which page is active on my website. I've figured out the logic part, but am having problem with the syntax and getting it to work, here is an example of what I"m doing: <div id="menu"> <ul> <li<?php echo ($navsection == 'home') ? ' class="act";' : "; ?>><a href="index.html">home</a></li> <li<?php echo ($navsection == 'company') ? ' class="act";' : "; ?>><a href="company.html">home</a></li> <li<?php echo ($navsection == 'services') ? ' class="act";' : "; ?>><a href="services.html">home</a></li> <li<?php echo ($navsection == 'contact') ? ' class="act";' : "; ?>><a href=contact.html">home</a></li> </ul> And then from there, each page gets this at the very top <?php $navsection = 'home'; ?> I'm getting an error that says Parse error: parse error, expecting `','' or `';'' in C:\wamp\www\template003\site\includes\toolbar.php on line 11 Basically my question is how can I write this line correctly <li<?php echo ($navsection == 'home') ? ' class="act";' : "; ?> Link to comment https://forums.phpfreaks.com/topic/174985-solved-php-to-find-out-which-page-is-active/ Share on other sites More sharing options...
PFMaBiSmAd Posted September 21, 2009 Share Posted September 21, 2009 That's because you are using one double-quote in the following part of your statement, instead to two single-quotes - : "; ?> Link to comment https://forums.phpfreaks.com/topic/174985-solved-php-to-find-out-which-page-is-active/#findComment-922222 Share on other sites More sharing options...
bruckerrlb Posted September 21, 2009 Author Share Posted September 21, 2009 thanks for your help, really dumb error on my part, after I fixed what you said, I kept getting some really weird errors, but after trying different things out, got it to work, thanks again! Link to comment https://forums.phpfreaks.com/topic/174985-solved-php-to-find-out-which-page-is-active/#findComment-922248 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.