$script_name problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mannyee
Forum Newbie
Posts: 10
Joined: Tue Dec 08, 2009 4:41 am

$script_name problem

Post 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
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: $script_name problem

Post 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'];
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
mannyee
Forum Newbie
Posts: 10
Joined: Tue Dec 08, 2009 4:41 am

Re: $script_name problem

Post 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.
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: $script_name problem

Post 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...
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
mannyee
Forum Newbie
Posts: 10
Joined: Tue Dec 08, 2009 4:41 am

Re: $script_name problem

Post 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'..............".
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: $script_name problem

Post 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.
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
mannyee
Forum Newbie
Posts: 10
Joined: Tue Dec 08, 2009 4:41 am

Re: $script_name problem

Post 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....
Post Reply