Jump to content

[SOLVED] Undefined Variables in included files - please help - desperate!


pollofrito

Recommended Posts

Hi, this is my first post here and I'm really hoping someone can help quickly as this is stopping me working in a big way!

 

I have a simple set up for my app. I have an index.php page which includes another php file (if needed) which would contain an auth.php to handle authentication if necessary. So, for example, for a user to go to his MyAccount page, the url would be:

 

http://www.example.com/myaccount. Using mod_rewrite, this passes myaccount to index.php as a $_GET variable, index.php loads myaccount.php using require_once and myaccount.php includes auth.php using require_once().

 

All clear and straight-forward so far...

 

SO here's the crunch. While variables should be global in scope automatically between included files, auth.php is not able to access anything at all.

 

For example, there is a class with static functions called LoginManager and both index.php and auth.php both reference a method of called isLoggedIn. There are no errors on index.php but as soon as auth.php tries to access the same file I get a fatal error.

 

To test the error, I set a simple variable called $_myVariable and set the value to "hello" in index.php. myaccount.php and auth.php *should* be able to see that variable and echo it out, but I get a notice about an undefined variable on that too from both pages.

 

The code (I believe) is sound and worked fine on my MacBook (apache 1.3, php5.2.4) during development - everything worked like a charm. However, moving the site to a staging server for my client's previews caused the failure, (apache2, php5.2.0-8-etch7). I've hunted and hunted and asked everyone I know who might have a clue and drawn a complete blank.

 

PLEASE PLEASE PLEASE can someone help me get this sorted as this is fundamental to me getting paid! If I don't get this fixed I'm in trouble. I'm sure it's an Apache/PHP config issue, but I can't find any obvious differences between the two setups that I've used and am really struggling to see the wood for the trees.

 

If I haven't been clear here, please ask and you can have any further information I can provide.

 

Cheers,

 

Pollo

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.