jsciarrino Posted January 23, 2009 Share Posted January 23, 2009 I upgraded from php 4.x to 5.2 and used to be able to use the following code successfully, now it's not working: <? if ($lan=="spanish") { ?> <p class="translate"><a href="page.php">english</a></p> <p>hola</p> <? } else { ?> <p class="translate"><a href="page.php?lan=spanish">english</a></p> <p>hello</p> <? } ?> Right now that code would only give me "hola" and clicking to translate to english doesn't change the text. Maybe a simple question, I'm very much a php newb. Thanks in advance. Quote Link to comment https://forums.phpfreaks.com/topic/142063-solved-php-upgrade-renders-my-old-page-translator-oddly/ Share on other sites More sharing options...
MadTechie Posted January 23, 2009 Share Posted January 23, 2009 read up on Register Globals which have been disabled in PHP5 and removed in PHP6 your Need to update your code ($lan to $_GET['lan']) <? if ($_GET['lan']=="spanish") { ?> <p class="translate"><a href="page.php">english</a></p> <p>hola</p> <? } else { ?> <p class="translate"><a href="page.php?lan=spanish">english</a></p> <p>hello</p> <? } ?> you could do $lan = $_GET['lan']; at the start of the page or extract($_GET) but i highly recommend you update your code correctly extracting user-input is a very bad move Quote Link to comment https://forums.phpfreaks.com/topic/142063-solved-php-upgrade-renders-my-old-page-translator-oddly/#findComment-743971 Share on other sites More sharing options...
jsciarrino Posted January 23, 2009 Author Share Posted January 23, 2009 Thanks so much, I fixed the code and it worked! Thanks for the speedy reply as well. Definitely need to brush up on my php, been a long time and the last time I used it was my first. Will "close" this thread. Thanks again. Quote Link to comment https://forums.phpfreaks.com/topic/142063-solved-php-upgrade-renders-my-old-page-translator-oddly/#findComment-743976 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.