wemustdesign Posted April 5, 2009 Share Posted April 5, 2009 Hi, I am having a problem and am not sure what is wrong. I am creating a menu for my site and am passing a variable to the menu so that is can highlight what page the user is on. I have declared the variable $lm2 as test. This echo's fine and outputs "test". The problem is when I try to echo the output in left_menu.php, nothing is outputted? How isn't left_menu.php not picking this up, the include is after I have declared the variable. You can see what I mean here http://www.photography.studio-for-hire.com/ as you can see the variable is outputted at the not but not at the menu section <? $lm2 = "test"; echo "Variable: $lm2"; ?> <? include "http://www.studio-for-hire.com/header.php"; ?> <div id="wrapper"> <div id="left_column"> <div class="bar_links"> <? include "http://www.studio-for-hire.com/left_menu.php"; ?> </div><!--bar_links--> </div><!--left column--> Link to comment https://forums.phpfreaks.com/topic/152634-variable-problem/ Share on other sites More sharing options...
Yesideez Posted April 5, 2009 Share Posted April 5, 2009 First, you're muct better off using long <?php tags instead of short <? tags - compatibility is the main reason. Second, can you post left_menu.php please? The problem will be in there. Link to comment https://forums.phpfreaks.com/topic/152634-variable-problem/#findComment-801580 Share on other sites More sharing options...
wemustdesign Posted April 5, 2009 Author Share Posted April 5, 2009 Here is the left_menu.php file <div class="arrowgreen"> <ul> <li><a href="http://www.photography.studio-for-hire.com" class="<? echo "$lm1"; ?>"title="Photography Studio for Hire">Photography Studio</a></li> <li><a href="http://www.dance.studio-for-hire.com" class="<? echo "$lm2"; ?>" title="Dance Studio for Hire">Dance Studios</a></li> <li><a href="http://www.recording.studio-for-hire.com" title="Recording Studio for Hire">Recording Studios</a></li> <li><a href="http://www.rehearsal.studio-for-hire.com" title="Rehearsal Studio for Hire">Rehearsal Studios</a></li> <li><a href="http://www.television.studio-for-hire.com" title="Television Studio for Hire">Television Studios</a></li> </ul> </div> <? echo "Variable: $lm2"?> Link to comment https://forums.phpfreaks.com/topic/152634-variable-problem/#findComment-801585 Share on other sites More sharing options...
Yesideez Posted April 5, 2009 Share Posted April 5, 2009 Bizarre! All I can suggest is try changing the short tags <? to how they should be <?php and remove the quotes around the variables, ie. <?php echo $lm2; ?> Not that it should make any difference but I can't see why your should shouldn't work! Link to comment https://forums.phpfreaks.com/topic/152634-variable-problem/#findComment-801589 Share on other sites More sharing options...
redarrow Posted April 5, 2009 Share Posted April 5, 2009 works with inline css <?php $lm1="STYLE='text-decoration: none;'"; $lm2="STYLE='text-decoration: none;'"; ?> <div class="arrowgreen"> <ul> <li><a href="http://www.photography.studio-for-hire.com" <?php echo "$lm1"; ?> title="Photography Studio for Hire">Photography Studio</a></li> <li><a href="http://www.dance.studio-for-hire.com" <?php echo "$lm2"; ?> title="Dance Studio for Hire">Dance Studios</a></li> <li><a href="http://www.recording.studio-for-hire.com" title="Recording Studio for Hire">Recording Studios</a></li> <li><a href="http://www.rehearsal.studio-for-hire.com" title="Rehearsal Studio for Hire">Rehearsal Studios</a></li> <li><a href="http://www.television.studio-for-hire.com" title="Television Studio for Hire">Television Studios</a></li> </ul> </div> <?php echo "Variable: $lm2"?> class way off doing it. <STYLE> a.redarrow1,a.redarrow{ text-decoration: none; } </STYLE> <?php $lm1="redarrow"; $lm2="redarrow1"; ?> <div class="arrowgreen"> <ul> <li><a href="http://www.photography.studio-for-hire.com" class="<?php echo "$lm1"; ?>" title="Photography Studio for Hire">Photography Studio</a></li> <li><a href="http://www.dance.studio-for-hire.com" class="<?php echo "$lm2"; ?>" title="Dance Studio for Hire">Dance Studios</a></li> <li><a href="http://www.recording.studio-for-hire.com" title="Recording Studio for Hire">Recording Studios</a></li> <li><a href="http://www.rehearsal.studio-for-hire.com" title="Rehearsal Studio for Hire">Rehearsal Studios</a></li> <li><a href="http://www.television.studio-for-hire.com" title="Television Studio for Hire">Television Studios</a></li> </ul> </div> <?php echo "Variable: $lm2"?> Link to comment https://forums.phpfreaks.com/topic/152634-variable-problem/#findComment-801597 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.