Sessions and MySQL query results....

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
linuxt
Forum Newbie
Posts: 2
Joined: Sun Mar 07, 2004 3:53 pm

Sessions and MySQL query results....

Post by linuxt »

Some how i cant get to print MySQL results using session values on the print statement...Heres the deal..
My config contains:

$lang_default = "en";

My header file contains:
PHP Code:

if (!session_is_registered('lang')){
$lang = $lang_default;
session_register('lang');
}
if (isset($new_lang)) {
$lang = "lang_".$new_lang.".php";
session_register('lang');
}

And all works fine. Ive checked with print_r($_SESSION);

Now the deal its this function in functions file:
PHP Code:
function makemenu(){
//include_once ("session_mysql.php");
session_start();
include ("config.php");
$menu2SQL= "SELECT * FROM config WHERE id='1'";
$blaman=mysql_query($menu2SQL);
while ($rekord=mysql_fetch_array($blaman))
{
$color2 = $rekord[color2];
}

$menu2SQL= "SELECT * FROM menu ORDER BY ordernr";
$blaman=mysql_query($menu2SQL);
while ($rekord=mysql_fetch_array($blaman))
{
if ($rekord[doshow]=="1"){
print "<TD bgColor=#$color2 height=\"2\">
<P align=center>&nbsp;&nbsp;<A
href=";
if ($rekord[link] == ""){
echo "index.php";
}
else{
print "$rekord[link]";
}
////HERE IS MY PROBLEM . THIS SHOWS NOTHING... :(
print ">$rekord[$lang]</A>&nbsp;&nbsp;</P></TD>";}
}
}



If i dont use sessions it works perfectly.......

Can someone help..Thanxxxxxxxxxxxxxxxxxx
User avatar
Stoker
Forum Regular
Posts: 782
Joined: Thu Jan 23, 2003 9:45 pm
Location: SWNY
Contact:

Post by Stoker »

Tip: Use the

Code: Select all

tag to enclose php code..
you may be abusing PHP capability to guess what you think what you want, this may not be the answer to your issue, but is definetely NOT a good practice, using $array[$hashname]  inside a parsed string (double quotes).
Personally I think that parsed strings should never be used unless you need \t \r \n and such, or at least that array-vars should never be used inside... example of bad practice that just slows down the process is the line [i]print "$rekord[link]";[/i], why use parsing quotes? It should be [i] echo $rekord['link'];[/i] 
anyway, perhaps your app works different if the problem line is changed to

echo '>' . $rekord[$lang] . '</a> </p></td>';
linuxt
Forum Newbie
Posts: 2
Joined: Sun Mar 07, 2004 3:53 pm

Still no deal..

Post by linuxt »

I made the changes you suggested but no deal..

It still as the some behaviour... :(
Post Reply