$_server['script_name']

Reply

Join Date: Apr 2008
Posts: 9
Reputation: phploveisgood is an unknown quantity at this point 
Solved Threads: 0
phploveisgood phploveisgood is offline Offline
Newbie Poster

$_server['script_name']

 
0
  #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 2:03 pm. Reason: Keep It Organized - please use [code] tags
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 596
Reputation: buddylee17 has a spectacular aura about buddylee17 has a spectacular aura about 
Solved Threads: 125
buddylee17's Avatar
buddylee17 buddylee17 is offline Offline
Posting Pro

Re: $_server['script_name']

 
0
  #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 Quick reply to this message  
Join Date: Apr 2008
Posts: 9
Reputation: phploveisgood is an unknown quantity at this point 
Solved Threads: 0
phploveisgood phploveisgood is offline Offline
Newbie Poster

Re: $_server['script_name']

 
0
  #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 2:03 pm. Reason: Keep It Organized - please use [code] tags
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 6
Reputation: jstorz is an unknown quantity at this point 
Solved Threads: 0
jstorz jstorz is offline Offline
Newbie Poster

Re: $_server['script_name']

 
0
  #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 2:04 pm. Reason: Keep It Organized - please use [code] tags
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 9
Reputation: phploveisgood is an unknown quantity at this point 
Solved Threads: 0
phploveisgood phploveisgood is offline Offline
Newbie Poster

Re: $_server['script_name']

 
0
  #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 2:05 pm. Reason: Keep It Organized - please use [code] tags
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 596
Reputation: buddylee17 has a spectacular aura about buddylee17 has a spectacular aura about 
Solved Threads: 125
buddylee17's Avatar
buddylee17 buddylee17 is offline Offline
Posting Pro

Re: $_server['script_name']

 
0
  #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 Quick reply to this message  
Join Date: Jan 2008
Posts: 71
Reputation: amigura is an unknown quantity at this point 
Solved Threads: 7
amigura's Avatar
amigura amigura is offline Offline
Junior Poster in Training

Re: $_server['script_name']

 
0
  #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

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

Re: $_server['script_name']

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

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

Re: $_server['script_name']

 
0
  #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.


  1. $bobo = strrpos($_SERVER['SCRIPT_FILENAME'], "/bobo/index.php");
  2. if ($bobo)
  3. {
  4. $style_home = 'style="background-color: #6C674F"';
  5. }
  6.  
  7. or
  8.  
  9. if ($_SERVER['REQUEST_URI']=="/bobo/index.php")
  10. {
  11. $style_home = 'style="background-color: #6C674F"';
  12. }
Last edited by amigura; May 11th, 2008 at 4:48 pm.
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 6
Reputation: jstorz is an unknown quantity at this point 
Solved Threads: 0
jstorz jstorz is offline Offline
Newbie Poster

Re: $_server['script_name']

 
0
  #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 Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC