You are here: Re: How to include optonial info when running on local server? « PHP Programming Language « IT news, forums, messages
Re: How to include optonial info when running on local server?

Posted by Paul Lautman on 09/01/07 11:40

Christian Aastorp wrote:
> I'm a newbie with php, but experienced with other languages. I'm
> maintaining a small site written in php. To ease debugging and updates
> I've used an onscreen reference to indicate identity of included files
> etc.
>
> I don't really want this reference to be visible to anyone but myself.
> So I searched the manual and found some promising predefined variables
> that I used in this code snippet:
>
> <?php
> if ($_SERVER['REMOTE_ADDR'] = "127.0.0.1") {
> echo $level1, '_', $level2, '_', $imageNO, ' ', $display;
> }
>>
>
> This worked spllendidly when I tested running our site locally using
> the XAMPP-bundle. But when I copied the code out to the real server it
> seems that all clients are found at 127.0.0.1!
>
> I'm sure there are lots of better ways both to fix my code, and
> especially totally different ways to do what I'm trying to achive, any
> suggestions very welcome!

As Michael pointed out, what you are actuall y doing here is assiging the
value "127.0.0.1" to the associative array element $_SERVER['REMOTE_ADDR'].

You should write:
<?php
if ($_SERVER['REMOTE_ADDR'] == '127.0.0.1') {
echo $level1, '_', $level2, '_', $imageNO, ' ', $display;
}
>
Note the == instead of = and also note the use of single instead of double
quotes around the string, which stops PHP from parsing the string to
discover if any substitution needs to take place.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация