Page 1 of 1

$script_name problem

Posted: Tue Dec 08, 2009 5:10 am
by mannyee
hello guys!!

I am new to php and currently working on some php tutorial for developing an e-commerce site. I came across a line of code:
$ME=$SCRIPT_NAME;

where $ME is a global variable. Thenafter, the script makes use of this variable many times to redirect to the same page shown in url and set values for some other variables. The problem is:
i) the above code of line shows up error
ii)when using $_SERVER['SCRIPT_NAME'] or ['PHP_SELF'] no error is displayed....but while
clicking on the link that makes use of $ME variable an error "Object Not Found" is displayed.

Currently, i am using the xampp 1.7.1 that bundles apache and php 5.3. Should i fix sth. in php.ini or sth else? help

Re: $script_name problem

Posted: Tue Dec 08, 2009 5:19 pm
by AbraCadaver
$SCRIPT_NAME would only be available if register_globals was on, which apparently its not (good thing).

Try:

Code: Select all

$ME = $_SERVER['SCRIPT_NAME'];

Re: $script_name problem

Posted: Thu Dec 10, 2009 2:49 am
by mannyee
Turning on register_globals didn't work.
I tried $_SERVER['SCRIPT_NAME'] too but the following error shows up in the browser:

Access forbidden!

You don't have permission to access the requested object. It is either read-protected or not readable by the server.

If you think this is a server error, please contact the webmaster.

Re: $script_name problem

Posted: Thu Dec 10, 2009 1:34 pm
by AbraCadaver
You need to do some debugging by printing some vars and different places. echo $ME; what is it? Is that a valid page? etc...

Re: $script_name problem

Posted: Sat Dec 12, 2009 3:37 am
by mannyee
Thank you for your suggestion.....I tried that and $ME=$_SERVER['SCRIPT_NAME'] is working fine.....

Can you give some other suggestion or a bit more explanation to your last suggestion:
You need to do some debugging by printing some vars and different places. echo $ME; what is it? Is that a valid page? etc...
I don't quite catch by what u said ".......'different places'..............".

Re: $script_name problem

Posted: Sat Dec 12, 2009 10:26 am
by AbraCadaver
Well, anywhere you use $ME, do an echo $ME; Is that a valid URL and does that page exist? That's what I meant, but you say it is working.

Re: $script_name problem

Posted: Sun Dec 13, 2009 10:42 am
by mannyee
Tried all bits and bytes but still can't find a way to solve the problem.....seems to me that the server is messed up (but am not sure). And of course thanks Shawn for your cooperation....and, will follow up your suggested link....