Welcome to WebmasterWorld Guest from 34.201.121.213

Forum Moderators: coopster & jatar k & phranque

Message Too Old, No Replies

problem with $ENV {'DOCUMENT_URI'}

variable retuens no value

     
2:39 pm on Feb 19, 2004 (gmt 0)

New User

10+ Year Member

joined:Feb 19, 2004
posts:7
votes: 0


hi,

im a new user to the forum.

I am using the hit counter script from Matt's script archive.

the script has no error but the count is not created. I think the $ENV{'DOCUMENT_URI'} variable returns no value at all.

Does anyone have a solution for this?

thanks,

11:48 am on Feb 20, 2004 (gmt 0)

Junior Member

10+ Year Member

joined:Feb 20, 2004
posts:48
votes: 0


Are you certain that the script have no error?
Remenber you are doing a counter and if i'm not misstaken you wouldn't get a "500 Int.server error" if the script had an error and the counter would always be on the default value.
Beside a scripting error it also can be the permitions you set or a server upload not in ASCII. Any of this situations wouldn't give you a 500 error in a counter, in some other scripts yes but not in a counter.
11:36 am on Feb 23, 2004 (gmt 0)

New User

10+ Year Member

joined:Feb 19, 2004
posts:7
votes: 0


hi, thank you!

i have uploaded the script in ASCII format and when i execute the script on command prompt, it works well and gives [TextCounter Fatal Error: Could Not Increment Counter].
When i run it in the browser, it is the same error.

i think this is bcoz the counter cannot write to the specified file in the folder but the folder has 777 permissions.

when tried replacing the $ENV{'DOCUMENT_URI'} with $ENV{'DOCUMENT_URI'}$ENV {'SCRIPT_NAME'} the script returns a number which is incremented every time it is executed.

But this does not happen when the file reference is added to the html page.

is there a way out of it!

thanks

4:16 pm on Feb 23, 2004 (gmt 0)

New User

10+ Year Member

joined:Aug 31, 2003
posts:19
votes: 0


Here are a couple of things to keep in mind -- for the directory that must be writable, look at permissions all the way down to the root, eg, if the folder is:

/home/user/website/counterdir

and counterdir has 777 perms, you might look at the permissions for home, user, and website -- try setting them liberally at first -- if that works, drop them back to the minimum permissions that retain functionality.

As far as the envirnonment variables go, realize that you're dealing with a different environment when you run the script from the command line from when you run it in the web server -- the web server sets a bunch of the http related environment variables, and they aren't going to be there from the command line. For debugging, if you have the CGI perl module installed (most boxes do) you can add this to the top of the script:

use CGI::Carp "fatalsToBrowser";

If it works, it'll show you a much more specific error in the browser. Be sure to comment out the line (with a #) when you're done, of course.

12:10 pm on Feb 24, 2004 (gmt 0)

New User

10+ Year Member

joined:Feb 19, 2004
posts:7
votes: 0


hi,
thanks again!

The script is now working on the command prompt.
When executed with the -W option, shows no errors at all.

The counter increments itself when run on command prompt but when i add the reference of the script to the webpage and open the webpage, the counter does not increment itself.

Is there still any error in the scriptwhich is not so obvious

i tried the CGI::Carp"fatalsToBrowser" but since the same subroutine already exists in the script had to comment it.

4:08 pm on Mar 3, 2004 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Mar 22, 2001
posts:2450
votes: 0


The next thing I would check would be the path and filename where you are calling it. Is everything spelled correctly? Is the path correct?
1:36 pm on Mar 6, 2004 (gmt 0)

Preferred Member

10+ Year Member

joined:Dec 19, 2000
posts:366
votes: 0


It sounds to me like there may not be an $ENV{'DOCUMENT_URI'} on your server.
You could try $ENV{'REQUEST_URI'} instead.