| | |
$_server['script_name']
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Apr 2008
Posts: 9
Reputation:
Solved Threads: 0
Please I need some help!
When I am developing, these code below works fine:
But, when I put on the server :
It won't work.
Please help me out.
Best regards
Max
When I am developing, these code below works fine:
php Syntax (Toggle Plain Text)
<?php if($_SERVER['SCRIPT_NAME'] == '/aktuelle seite/index.php') { $style_home = 'style="background-color: #6C674F"'; } ?> <ul> <li class="linkLevel01"><a href="index.php" class="homy"<?php echo $style_home ?>>Home</a></li>
But, when I put on the server :
php Syntax (Toggle Plain Text)
<?php if($_SERVER['SCRIPT_NAME'] == '/bobo/index.php') //"bobo" is the name of the folder on my server] { $style_home = 'style="background-color: #6C674F"'; } ?> <ul> <li class="linkLevel01"><a href="index.php" class="homy"<?php echo $style_home ?>>Home</a></li>
It won't work.
Please help me out.
Best regards
Max
Last edited by peter_budo; May 11th, 2008 at 2:03 pm. Reason: Keep It Organized - please use [code] tags
echo or print the variable to see what it actually is.
php Syntax (Toggle Plain Text)
<?php if($_SERVER['SCRIPT_NAME'] == '/bobo/index.php') { $style_home = 'style="background-color: #6C674F"'; } echo $_SERVER['SCRIPT_NAME']; ?>
•
•
Join Date: Apr 2008
Posts: 9
Reputation:
Solved Threads: 0
Excuse me! I don't realy understand what you mean. These are my code:
What would you have done to make it work.
php Syntax (Toggle Plain Text)
<?php if($_SERVER['SCRIPT_NAME'] == '/bobo/index.php') { $style_home = 'style="background-color: #6C674F"'; } ?> <ul> <li class="linkLevel01"><a href="index.php" class="homy"<?php echo $style_home ?>>Home</a></li>
What would you have done to make it work.
Last edited by peter_budo; May 11th, 2008 at 2:03 pm. Reason: Keep It Organized - please use [code] tags
•
•
Join Date: May 2008
Posts: 6
Reputation:
Solved Threads: 0
try this,
instead of
or like was said above just echo $_SERVER['SCRIPT_NAME'] ; to see what the variable actually is and adjust from there.
php Syntax (Toggle Plain Text)
if (preg_match("/bobo\/index.php/i",$_SERVER['REQUEST_URI'])) { $style_home = 'style="background-color: #6C674F"'; }
instead of
php Syntax (Toggle Plain Text)
if($_SERVER['SCRIPT_NAME'] == '/bobo/index.php') { $style_home = 'style="background-color: #6C674F"'; }
or like was said above just echo $_SERVER['SCRIPT_NAME'] ; to see what the variable actually is and adjust from there.
•
•
•
•
Excuse me! I don't realy understand what you mean. These are my code:
<?php
if($_SERVER['SCRIPT_NAME'] == '/bobo/index.php')
{
$style_home = 'style="background-color: #6C674F"';
}
?>
<ul>
<li class="linkLevel01"><a href="index.php" class="homy"<?php echo $style_home ?>>Home</a></li>
What would you have done to make it work.
Last edited by peter_budo; May 11th, 2008 at 2:04 pm. Reason: Keep It Organized - please use [code] tags
•
•
Join Date: Apr 2008
Posts: 9
Reputation:
Solved Threads: 0
I have tried the code you send to me, but it did not work.
And when I tried the first code you sent:
It only eched the word "index.php", not the style.
Thanks one more time for efforts. Please I am open for more helps
Best regards.
And when I tried the first code you sent:
php Syntax (Toggle Plain Text)
<?php if($_SERVER['SCRIPT_NAME'] == '/bobo/index.php') { $style_home = 'style="background-color: #6C674F"'; } echo $_SERVER['SCRIPT_NAME']; ?>
It only eched the word "index.php", not the style.
Thanks one more time for efforts. Please I am open for more helps
Best regards.
Last edited by peter_budo; May 11th, 2008 at 2:05 pm. Reason: Keep It Organized - please use [code] tags
Okay, that means that $_SERVER['SCRIPT_NAME'] equals index.php. Therefore, compare the current page($_SERVER['SCRIPT_NAME']) to index.php:
php Syntax (Toggle Plain Text)
<?php if($_SERVER['SCRIPT_NAME'] == 'index.php') { $style_home = 'style="background-color: #6C674F"'; } ?>
comparing $_SERVER['SCRIPT_NAME'] == 'index.php' will not work for you as /bobo/index.php' and '/aktuelle seite/index.php' will give same style.
try below to see wat you get
try below to see wat you get
PHP Syntax (Toggle Plain Text)
echo $_SERVER['PHP_SELF'];
hmm for both $_SERVER['SCRIPT_NAME'] and $_SERVER['PHP_SELF'] not to work you might have a problem with your php.
PHP Syntax (Toggle Plain Text)
$bobo = strrpos($_SERVER['SCRIPT_FILENAME'], "/bobo/index.php"); if ($bobo) { $style_home = 'style="background-color: #6C674F"'; } or if ($_SERVER['REQUEST_URI']=="/bobo/index.php") { $style_home = 'style="background-color: #6C674F"'; }
Last edited by amigura; May 11th, 2008 at 4:48 pm.
•
•
Join Date: May 2008
Posts: 6
Reputation:
Solved Threads: 0
Perhaps we are not hearing the whole story. Would "bobo" happen to be a subdomain instead of a subfolder? This would cause script_name and all the rest to just spit out index.php.
So is it? a subdomain would look like this [[ www.bobo.domain.com ]] instead of [[ www.domain.com/bobo/ ]]
So is it? a subdomain would look like this [[ www.bobo.domain.com ]] instead of [[ www.domain.com/bobo/ ]]
![]() |
Similar Threads
- Help beta testing new CMS (PHP)
- url splitting (PHP)
- code output not correct (PHP)
- Making a static but yet a dynamic navigation (PHP)
- Need HELP in pagination (PHP) (PHP)
- pagination of mysql query results (PHP)
- Font Size Problem (PHP)
- Display URL (PHP)
- Error getting forms to send information (PHP)
Other Threads in the PHP Forum
- Previous Thread: Remove Non Printing Characters From Text
- Next Thread: help with code
| Thread Tools | Search this Thread |
.htaccess ajax apache api array back basic beginner binary broken cakephp checkbox class cms code computing cron curl customizableitems database date delete display dynamic echo email error file files filter folder form forms function functions gc_maxlifetime google host href htaccess html image include insert integration ip java javascript joomla limit link login loop mail memmory memory menu mlm mod_rewrite multiple mysql navigation oop parsing paypal pdf php problem query radio random recursion regex remote script search server sessions sms snippet soap source space sql syntax system table thesishelp trouble tutorial update upload url validation validator variable video web xml youtube





