umpljazz
11-27-2005, 03:39 PM
Ok guys I'm wanting to write a seperate PHP function that'll be used whenever it is to be checked that a user is logged in and pass their username into a variable.
Currently it's like this...
function getUserName()
{
chdir("./forum/"); // directs script to the forum - to check logged in status
include('global.php'); //includes file containing user status details
chdir("../"); //directs script back to original page
return $bbuserinfo[username];
}
I know that the relitive locations will have to be altered each time the function is used (parhaps put as arguments into the function) but that isn't the problem at the moment!
The problem is when I goto call the function from another page...
include('includes/sitefunctions.php');
echo (getUserName());
I get the following error...
Fatal error: Call to undefined function: query_first() in ...../public_html/forum/includes/functions.php on line 938
If I use the above code in its own file without using it as a function it works like a dream.
Any advice is appreciated.
Cheers
Currently it's like this...
function getUserName()
{
chdir("./forum/"); // directs script to the forum - to check logged in status
include('global.php'); //includes file containing user status details
chdir("../"); //directs script back to original page
return $bbuserinfo[username];
}
I know that the relitive locations will have to be altered each time the function is used (parhaps put as arguments into the function) but that isn't the problem at the moment!
The problem is when I goto call the function from another page...
include('includes/sitefunctions.php');
echo (getUserName());
I get the following error...
Fatal error: Call to undefined function: query_first() in ...../public_html/forum/includes/functions.php on line 938
If I use the above code in its own file without using it as a function it works like a dream.
Any advice is appreciated.
Cheers