pollofrito Posted October 31, 2007 Share Posted October 31, 2007 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 Quote Link to comment https://forums.phpfreaks.com/topic/75482-solved-undefined-variables-in-included-files-please-help-desperate/ Share on other sites More sharing options...
pollofrito Posted October 31, 2007 Author Share Posted October 31, 2007 anyone? Quote Link to comment https://forums.phpfreaks.com/topic/75482-solved-undefined-variables-in-included-files-please-help-desperate/#findComment-381835 Share on other sites More sharing options...
pollofrito Posted October 31, 2007 Author Share Posted October 31, 2007 Aha! Found the problem. Seems I had left an important Option out of my vhost configuration file. Changed to Options All and it solved the problem. Thanks for reading even if no one helped! Quote Link to comment https://forums.phpfreaks.com/topic/75482-solved-undefined-variables-in-included-files-please-help-desperate/#findComment-381873 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.