•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 361,569 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,064 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 717 | Replies: 19
![]() |
| |
•
•
Join Date: Apr 2008
Posts: 9
Reputation:
Rep Power: 0
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 1: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:
Rep Power: 0
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 1:03 pm. Reason: Keep It Organized - please use [code] tags
•
•
Join Date: May 2008
Posts: 6
Reputation:
Rep Power: 0
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 1:04 pm. Reason: Keep It Organized - please use [code] tags
•
•
Join Date: Apr 2008
Posts: 9
Reputation:
Rep Power: 0
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 1: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
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.
$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 3:48 pm.
•
•
Join Date: May 2008
Posts: 6
Reputation:
Rep Power: 0
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/ ]]
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb PHP Marketplace
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


Hybrid Mode