Jump to content

[SOLVED] Variables and functions in different files


envexlabs

Recommended Posts

Hey,

 

I have 2 files, index.php and functions.php

 

in index.php

<?php if ($au=$_SESSION['_amember_user']){ // user is logged-in
print "<p>Hello $au[name_f] $au[name_l]!</p><br>";
print "<a href='/amember/logout.php'>Logout</a>";
} 
else { // user is not logged-in
                    
print '<p>Hello!</p>
<a href="javascript:login_fade();">Login</a>';

}?>

display_nav();

 

in functions.php

 

function display_nav(){
    $nav_display = mysql_query('SELECT * FROM `amember_payments` WHERE `member_id` = "' . $au[member_id] . '"');
    $nav = mysql_fetch_row($nav_display);
    
    //renders out the navigation depending on the user
    if($nav[2] == 1)
    {
        //user
        user_nav();
    }
    elseif($nav[2] == 2 || $nav[2] == 3)
    {
        //store
        store_nav();
    }
    else{
        //guest
    }
}

 

I have included the functions.php in index.php, but for some reason display_nav(); doesn't work. If i copy the function into index.php it works.

 

Why are my variables from index.php not working in function.php even though function.php is included in index.php

 

Any help is appreciated!

 

Thanks.

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.