Jump to content

[SOLVED] php upgrade renders my old page translator oddly


jsciarrino

Recommended Posts

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.

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.