Code Glitch : If its the same thing why doesnt it work
Posted: Thu Oct 25, 2012 7:49 am
Ive got a database with a bunch of translations and my site initially checks if the user has set a language, if not then it checks the browser language and uses that.The translations are stuck into an array. This language code is used around the site and i had everything working nicely. On a few of the pages i decided to tidy us the code a bit to cut down on how many lines there were and then all came to a grinding halt. I dont know why since in theory its the exact same code....
Original code
Second Code that freezes the site
Original code
Code: Select all
if (strlen(mysql_real_escape_string($_GET['lang'])) == 2){$lc = mysql_real_escape_string($_GET['lang']);};
$lar = array('empty');
$langselect = "SELECT * FROM lang ORDER BY lid";
$langf = mysql_query($langselect, $dbConn);
while ($lf = mysql_fetch_array($langf, MYSQL_ASSOC)) {
$lar[] = $lf[$lc];
}Code: Select all
if (strlen(mysql_real_escape_string($_GET['lang'])) == 2){$lc = mysql_real_escape_string($_GET['lang']);};
$lar = array('empty');while ($lf = mysql_fetch_array(mysql_query("SELECT * FROM lang ORDER BY lid", $dbConn), MYSQL_ASSOC)) {$lar[] = $lf[$lc];}