greenbman Posted February 11, 2013 Share Posted February 11, 2013 ok so on the following code the NavMenuEng.php appears correctly however the NavMenuSpan.php does not appear however in the source code the NavMenuSpan.php is there just like the Eng one. Here is the code: <?php session_start(); $_SESSION['lang'] = 0; if(isset($_GET['lang'])){ if($_GET['lang']=='eng'){ $_SESSION['lang'] = 0; }else if($_GET['lang']=='span'){ $_SESSION['lang'] = 1; } } ?> <center><a href="index.php?lang=eng"><img title="English" src="images/english.png"></a> <a href="index.php?lang=span"><img title="Spanish" src="images/spanish.png"></a></center> <?php switch($_SESSION['lang']){ case 0: include("NavMenuEng.php"); break; case 1: include("NavMenuSpan.php"); break; default: include("NavMenuEng.php"); break; } ?> And this is the NavMenuEng.php: <div id="menu"> <ul> <li class="active"><a href="index.php" accesskey="1" title="Home">Homepage</a></li> <li><a href="skills.php" accesskey="2" title="Skills">Skills</a></li> <li><a href="reffs.php" accesskey="3" title="References">References</a></li> <li><a href="about_me.php" accesskey="4" title="About Me!">About Me</a></li> <li><a href="contact_me.php" accesskey="5" title="Contact Me!">Contact Me</a></li> </ul> </div> And this is the NavMenuSpan.php: <div id="menu"> <ul> <li class="active"><a href="index.php" accesskey="1" title="Home">Página Principal</a></li> <li><a href="skills.php" accesskey="2" title="Skills">Habilidades</a></li> <li><a href="reffs.php" accesskey="3" title="References">Referencias</a></li> <li><a href="about_me.php" accesskey="4" title="About Me!">Acerca de mí</a></li> <li><a href="contact_me.php" accesskey="5" title="Contact Me!">Contacto</a></li> </ul> </div> Hopefully someone can help with this. Thank you all for the Views. gbman Quote Link to comment Share on other sites More sharing options...
greenbman Posted February 11, 2013 Author Share Posted February 11, 2013 (edited) hmm I can't figure this out. weird as heck Edited February 11, 2013 by greenbman Quote Link to comment Share on other sites More sharing options...
Kingy Posted February 11, 2013 Share Posted February 11, 2013 if you echo out the session variable can you see that it is getting set to spanish? Quote Link to comment Share on other sites More sharing options...
Psycho Posted February 11, 2013 Share Posted February 11, 2013 (edited) On a side note, you have a lot of unnecessary code in there. You set $_SESSION['lang'] to a default of 0 to start. Then you have a if() condition that will set it to 0 if a condition is met. Why, you already set it to 0 to begin with right? Then you put a default case in your switch statement and also duplicate the code for the 1 condition. Anyway, that 0 or 1 values are a waste. It makes it more difficult to read in your code and is not intuitive. As to why you are not seeing the spanish content, my guess would be that you aren't actually sending 'span' on the query string as you think you are. Try echoing out $_GET['lang'] to the page. This code will work much better and I've included a couple debugging lines <?php session_start(); if(isset($_GET['lang'])) { $_SESSION['lang'] = strtolower(trim($_GET['lang'])); } ?> <center><a href="index.php?lang=eng"><img title="English" src="images/english.png"></a> <a href="index.php?lang=span"><img title="Spanish" src="images/spanish.png"></a></center> <?php //Debugging lines (Uncomment to debug) //echo "\$_GET['lang']: {$_GET['lang']}<br>"; //echo "\$_SESSION['lang']: {$_SESSION['lang']}<br>"; switch($_SESSION['lang']) { case 'span': include("NavMenuSpan.php"); break; case 'eng': default: include("NavMenuEng.php"); break; } ?> Edited February 11, 2013 by Psycho Quote Link to comment Share on other sites More sharing options...
greenbman Posted February 11, 2013 Author Share Posted February 11, 2013 Thanks guys but I put up a subdomain with a copy of the site in different languages so each language has it's own subdomain and it works sufficiently. But I do like the debugging setup you have there Psycho thanks guys. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.