Hmm.  Here's how you can make it load EVERYtime the file is included, plain
and simply.  In the include file, create the function.and the call it after
you've made it.  To get the other function to work, you might want to try
placing the function ABOVE checkMaster();
 (you should probably simply put that in the same file, but above it).
functions.php
<?
function myfunction () {}

myfunction();
?>

I have the feeling that the problem with the session variable is that you're
calling it before anything has been done to define it in the main page, so
it is null when you check it.  Try debugging it with echo statements here
and there that call out variables so that you know they're defined
correctly.  Also, turn on "error_reporting(E_ALL);" (you can simply call it
at the top of the page--first thing).  That will tell you when variables are
used if they're null and other errors that aren't fatal, but might cause
problems.

"Jon Wyatt" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
>
> I have some pages which include a number of files.
> In one of the include files I have a function which I wish to be executed
> everytime the include file is loaded.
>
> Therefore I place the function name in the include file at the top.
>
> However, this function uses a session variable to decide whether to call
> another function and it appears that this variable is not being carried
> across. For example, the start of the include file might look like this:-
>
>
> <?php
>
> checkMaster();
>
>
> function checkMaster()
> {
>         global $master_session;
>         if ($master_session[db_host])
>         {
>                 connectToDB();
>         }
> }
>
>
> function connectToDB()
> {
> ...
> ....
>
>
> The master_session variable is not set and hence connectToDB is never
> called.
> If I place the checkMaster code in each page that includes this file then
it
> all works fine. How do I get round this?
>
> Thanks.
>
> jon.
>
> Better than having your body rubbed vigorously with a cheese grater.
> http://www.samuri.co.uk.
>
>
> _________________________________________________________________
> MSN Photos is the easiest way to share and print your photos:
> http://photos.msn.com/support/worldwide.aspx
>



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to