PDA

View Full Version : PHP Rears Its Ugly Head once again...


ManagerJosh
Tue 16th Nov '04, 7:09am
Okay, so this is just odd. On one of my sites (which is on server a) this script works, however on my primary site (which is on server a) this script doesn't work

I downloaded and reuploaded the script and basic sql data over and over and over and the blasted thing doesn't work

in globals.php, I have this:

$get_lang = mysql_query("select `thetext`,`taginserts`,`name` from `ezdatabase_lang`"); $GLOBALS['query_count']++;
while ($lang_info = mysql_fetch_array($get_lang))
{
$GLOBALS['lang'][$lang_info['name']] = array("thetext"=>$lang_info['thetext'],"taginserts"=>$lang_info['taginserts']);
}


and in functions.php

function lang($name)
{
$text = $GLOBALS['lang'][$name]['thetext'];
$taginserts = $GLOBALS['lang'][$name]['taginserts'];

$taginserts_line = explode("\n",$taginserts);

foreach ($taginserts_line as $line)
{
$tag = explode("|", $line);
global $$tag[0];
}

$text = stripslashes($text);
$text = stripslashes($text);
$text = stripslashes($text);
$text = stripslashes($text);
$text = addslashes($text);
eval ("\$text = \"$text\";");

if($text)
return $text;
else
return '<b>Invalid Language Reference</b>';
}

Primary site gets a Invalid Language Reference while my other site doesn't

Argh! What's going wrong here!!

Alan @ CIT
Tue 16th Nov '04, 7:38am
By the looks of it, the data is stuffed into $text at the very beginging of lang(). It's getting that data from the SQL query in globals.php. It's likely then that your SQL query is failed for some reason and not returning any data to be stuffed into $text.

Change:
$get_lang = mysql_query("select `thetext`,`taginserts`,`name` from `ezdatabase_lang`"); $GLOBALS['query_count']++;
To:

$get_lang = mysql_query("select `thetext`,`taginserts`,`name` from `ezdatabase_lang`") or die(mysql_error()); $GLOBALS['query_count']++;

And see if it pops up any errors that might give a clue as to the problem.

Thanks,
Alan.

ManagerJosh
Tue 16th Nov '04, 8:12am
Nope...nothing

Alan @ CIT
Tue 16th Nov '04, 8:26am
Hmm... ok, next test then - on the line following:

$text = $GLOBALS['lang'][$name]['thetext'];

Put:

die($text);

And it will either throw up a blank page ($text contains nothing) or will echo whatever $text contains.

If that comes up as a blank page, change it to:

die($name); and see if that outputs anything.

Thanks,
Alan.

ManagerJosh
Tue 16th Nov '04, 2:10pm
die($name); echos out a reference to bit of data stored within the ezdatabase_lang table


The "login_bar_guest" language variable. I checked, and its there

Alan @ CIT
Wed 17th Nov '04, 6:25am
Did die($text) come out with a blank page or some text? If it was blank, something is definatly going wrong in your mysql query.

Thanks,
Alan.

ManagerJosh
Wed 17th Nov '04, 7:12am
yea, die($text) did come out with a blank page. I'll have to look back and see what I did wrong.

Alan @ CIT
Wed 17th Nov '04, 7:24am
Definatly looks like it's something wrong with the query in your globals.php then as $text gets it's data from the results of that query.

Good luck bug hunting :)

Alan.

ManagerJosh
Sat 20th Nov '04, 5:55am
okay I found the problem...one of my devs commented this out because he rewrote how it accesses all the language parameters because the server was being over taxed.

Above $text = $GLOBALS['lang'][$name]['thetext'];
$taginserts = $GLOBALS['lang'][$name]['taginserts'];</FONT>

he originally had this.

$getlang = mysql_query("select * from ezdatabase_lang where name='$name'");
$lang = @mysql_fetch_array($getlang);


But he replaced it with this..

$get_lang = mysql_query("select `thetext`,`taginserts`,`name` from `ezdatabase_lang`"); $GLOBALS['query_count']++;
while ($lang_info = mysql_fetch_array($get_lang))
{
$GLOBALS['lang'][$lang_info['name']] = array("thetext"=>$lang_info['thetext'],"taginserts"=>$lang_info['taginserts']);
} </FONT>