Jump to content

Constant not holding...


rbrown

Recommended Posts

I can't figure this out... Trying set the constant on the first page

which is at:

/acl/redirect.php

 

define('PATHTOINCLUDES', dirname($_SERVER["SCRIPT_FILENAME"]));
/* include the functions and config files */
include (PATHTOINCLUDES.'/config.php');
include (PATHTOINCLUDES.'/functions.php');

 

Then it redirects to:

/acl/admin/adminpage.php

 

And the adminpage.php has the two include lines and I'm getting:

 

Notice: Use of undefined constant PATHTOINCLUDES - assumed 'PATHTOINCLUDES' in C:\a\UniServer\www\acl\admin\adminpage.php on line 9

 

Warning: include(PATHTOINCLUDES/config.php) [function.include]: failed to open stream: No such file or directory in C:\a\UniServer\www\acl\admin\adminpage.php on line 9

 

I have error_reporting = E_ALL set in the php.ini so it makes sure I write code with defined vars and no errors.

 

So I'm not getting why I'm getting the notice since I do have the Constant quoted in the define statement and why it isn't being passed to the next page.

 

I did have session vars and anti page caching code and I ripped all that out of the code thinking that was a problem... but didn't make any difference.

 

Or am I missing something else?

 

Link to comment
Share on other sites

I see...

I missunderstood how they worked.

Was trying something different...

Instead of hard coding the includes on every page, like I normally do, was trying to make them all the same.

I'm fixing code someone else wrote.

There are a ton of pages and directories...

It's a real mess...

So I guess I'll try sessions and see how that works.

Thanks... 

Link to comment
Share on other sites

Storing include locations in the session could be a bad idea. What happens if the session expires or doesn't exist and a user views a page that doesn't have the vars being set?

 

If there's a script that all of the others are including, such as a database connection script then you could put your constants and other includes there, so they'll be present on all pages that include that script.

Link to comment
Share on other sites

True... but it does have session checking so if the session expires it takes them back to the login page where the include would be reset. So I'm thinking that would / should work.

 

I'm also thinking about writing a script to figure out where the calling page is in relation to the includes pages.

I'll probably do that instead since I thinking about putting the config file below web root.

 

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.