User Name Password Register
DaniWeb IT Discussion Community
All
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
Reply
Join Date: Apr 2008
Posts: 9
Reputation: phploveisgood is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
phploveisgood phploveisgood is offline Offline
Newbie Poster

$_server['script_name']

  #1  
May 9th, 2008
Please I need some help!

When I am developing, these code below works fine:

  1. <?php
  2. if($_SERVER['SCRIPT_NAME'] == '/aktuelle seite/index.php')
  3. {
  4. $style_home = 'style="background-color: #6C674F"';
  5. }
  6. ?>
  7. <ul>
  8.  
  9. <li class="linkLevel01"><a href="index.php" class="homy"<?php echo $style_home ?>>Home</a></li>


But, when I put on the server :

  1. <?php
  2. if($_SERVER['SCRIPT_NAME'] == '/bobo/index.php')
  3. //"bobo" is the name of the folder on my server]
  4. {
  5. $style_home = 'style="background-color: #6C674F"';
  6. }
  7. ?>
  8. <ul>
  9.  
  10. <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
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Nov 2007
Location: Arkansas
Posts: 176
Reputation: buddylee17 is on a distinguished road 
Rep Power: 1
Solved Threads: 32
buddylee17's Avatar
buddylee17 buddylee17 is offline Offline
Junior Poster

Re: $_server['script_name']

  #2  
May 9th, 2008
echo or print the variable to see what it actually is.
  1. <?php
  2. if($_SERVER['SCRIPT_NAME'] == '/bobo/index.php') {
  3. $style_home = 'style="background-color: #6C674F"';
  4. }
  5. echo $_SERVER['SCRIPT_NAME'];
  6. ?>
Reply With Quote  
Join Date: Apr 2008
Posts: 9
Reputation: phploveisgood is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
phploveisgood phploveisgood is offline Offline
Newbie Poster

Re: $_server['script_name']

  #3  
May 9th, 2008
Excuse me! I don't realy understand what you mean. These are my code:

  1. <?php
  2. if($_SERVER['SCRIPT_NAME'] == '/bobo/index.php')
  3. {
  4. $style_home = 'style="background-color: #6C674F"';
  5. }
  6. ?>
  7. <ul>
  8.  
  9.  
  10. <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
Reply With Quote  
Join Date: May 2008
Posts: 6
Reputation: jstorz is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
jstorz jstorz is offline Offline
Newbie Poster

Re: $_server['script_name']

  #4  
May 10th, 2008
try this,

  1. if (preg_match("/bobo\/index.php/i",$_SERVER['REQUEST_URI'])) {
  2. $style_home = 'style="background-color: #6C674F"';
  3. }

instead of

  1. if($_SERVER['SCRIPT_NAME'] == '/bobo/index.php')
  2. {
  3. $style_home = 'style="background-color: #6C674F"';
  4. }

or like was said above just echo $_SERVER['SCRIPT_NAME'] ; to see what the variable actually is and adjust from there.

Originally Posted by phploveisgood View Post
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
Reply With Quote  
Join Date: Apr 2008
Posts: 9
Reputation: phploveisgood is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
phploveisgood phploveisgood is offline Offline
Newbie Poster

Re: $_server['script_name']

  #5  
May 10th, 2008
I have tried the code you send to me, but it did not work.

And when I tried the first code you sent:
  1. <?php
  2. if($_SERVER['SCRIPT_NAME'] == '/bobo/index.php')
  3. {
  4. $style_home = 'style="background-color: #6C674F"';
  5. }
  6. echo $_SERVER['SCRIPT_NAME'];
  7. ?>

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
Reply With Quote  
Join Date: Nov 2007
Location: Arkansas
Posts: 176
Reputation: buddylee17 is on a distinguished road 
Rep Power: 1
Solved Threads: 32
buddylee17's Avatar
buddylee17 buddylee17 is offline Offline
Junior Poster

Re: $_server['script_name']

  #6  
May 10th, 2008
Okay, that means that $_SERVER['SCRIPT_NAME'] equals index.php. Therefore, compare the current page($_SERVER['SCRIPT_NAME']) to index.php:
  1. <?php
  2. if($_SERVER['SCRIPT_NAME'] == 'index.php')
  3. {
  4. $style_home = 'style="background-color: #6C674F"';
  5. }
  6. ?>
Reply With Quote  
Join Date: Jan 2008
Posts: 71
Reputation: amigura is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 7
amigura's Avatar
amigura amigura is offline Offline
Junior Poster in Training

Re: $_server['script_name']

  #7  
May 11th, 2008
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

echo $_SERVER['PHP_SELF'];
Reply With Quote  
Join Date: Apr 2008
Posts: 9
Reputation: phploveisgood is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
phploveisgood phploveisgood is offline Offline
Newbie Poster

Re: $_server['script_name']

  #8  
May 11th, 2008
I have tried the code, but did not work.

Regards
Reply With Quote  
Join Date: Jan 2008
Posts: 71
Reputation: amigura is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 7
amigura's Avatar
amigura amigura is offline Offline
Junior Poster in Training

Re: $_server['script_name']

  #9  
May 11th, 2008
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.
Reply With Quote  
Join Date: May 2008
Posts: 6
Reputation: jstorz is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
jstorz jstorz is offline Offline
Newbie Poster

Re: $_server['script_name']

  #10  
May 11th, 2008
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/ ]]
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb PHP Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the PHP Forum

All times are GMT -4. The time now is 3:06 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC