NYCPHP Meetup

NYPHP.org

[nycphp-talk] relative newbie needs installation help

Hans Zaunere zaunere at yahoo.com
Thu Jun 6 10:00:09 EDT 2002


On a 4.1.2 install of PHP, I turned register_globals = On in php.ini
and stopped/started apache.  Voila, $HTTP_USER_AGENT is found.  So, you
might not be getting the proper setting of register_globals, and even
in 4.2.x this should still work.

However, I would move away from this, since depending on globally
scoped variables and register_globals is being deprecated quickly.
For this situation, get_browser() may be the way to go.

Hans Z.


--- Michael Southwell <MSouthwell at bigfoot.com> wrote:
> Many thanks, Hans; this makes it work perfectly.  I will now proceed
> to 
> struggle through the documentation to try to figure out exactly how
> this is 
> different from the original, and why this works while the other 
> didn't.  Thanks also to others who chimed in; this list is very
> helpful!
> 
> At 06:42 PM 6/4/2002, you wrote:
> 
> >Change:
> >   $agent=$HTTP_USER_AGENT;
> >
> >to:
> >   $agent=$_SERVER['HTTP_USER_AGENT'];
> >
> >and that should do the trick.  From first thought, this seems like a
> >register_globals problem, but maybe it's track_vars or
> variable_order
> >or something.  Can't remember off the top.  Do a phpinfo(); to
> confirm
> >that that var is actually getting created as well.
> >
> >HZ
> >
> >
> >--- Michael Southwell <southwell at dneba.com> wrote:
> > > Thanks, Klaus.  This suggestion sounded promising but didn't
> work.  I
> > >
> > > changed register_globals to On and
> > > rebooted.  But I still got the following error:
> > >
> > > Notice:  Undefined variable:  HTTP_USER_AGENT in
> > > g:\\dneba\\browsers.php on
> > > line 50
> > >
> > > Here is the relevant code (it is obvious which is line 50):
> > >
> > > <CODE>
> > > Your choice of web browser is the single most important factor in
> > > controlling your experience
> > > of a website.  Your browser seems to be
> > >
> > > <?php
> > >    $agent=$HTTP_USER_AGENT;
> > >
> > >    $brow="";
> > >
> > >    if ($brow==""){
> > >      $pos=strpos($agent,"MSIE");
> > >      if ($pos>0){
> > >        $brow="MSIE";
> > >        $level=substr($agent,$pos+5,3);
> > >        $new=1;}}
> > > </CODE>
> > >
> > > I think $HTTP_USER_AGENT is about as basic a variable as you can
> > > get.  Needless to say,
> > > this code works perfectly (within its limitations, which no doubt
> are
> > >
> > > plenty) at http://www.dneba.com/browsers.php.
> > >
> > > So there must be something else going on.
> > >
> > > At 03:10 PM 6/4/2002, you wrote:
> > >
> > > >My first guess is it's a register_globals problem. 
> register_globals
> > > is
> > > >turned off by default in 4.2.1.  CGI vs Apache module shouldn't
> make
> > > a
> > > >difference in this case (I'm assuming you are only using the
> basic
> > > >variables, such as the post,get,server variables).
> > > >
> > > >As a quick fix, goto your php.ini and find the register_globals
> > > >directive, changing it to 'On'.  If this works, let us know; if
> not,
> > > >what specific variables does it report it can't find/are
> undefined?
> > > >
> > > >Hans Z.
> > > >
> > > >
> > > >--- Michael Southwell <southwell at dneba.com> wrote:
> > > > > I have some scripts that are working beautifully on the host
> but
> > > are
> > > > > not
> > > > > working on my localhost installation (which I thought I had
> > > gotten
> > > > > working):  PHP 4.2.1 running under Apache 1.3.24 on Windows
> XP.
> > > The
> > > > > problem comes in recognizing variables locally, so I get
> > > "undefined
> > > > > variable" and "undefined constant" messages.  PHPInfo() tells
> me
> > > that
> > > > > my
> > > > > local Server API is CGI, while on the host it's Apache.  I am
> > > > > guessing that
> > > > > this is the cause of the problems, though I don't really
> > > understand
> > > > > the
> > > > > difference.  Can anybody offer an explanation/possible
> solution?
> > > > > TIA.
> > > > >
> > > > > Michael G. Southwell =================================
> > > > > DNEBA Enterprises
> > > > > 81 South Road
> > > > > Bloomingdale, NJ 07403-1425
> > > > > 973/492-7873 (voice and fax)
> > > > > southwell at dneba.com
> > > > > http://www.dneba.com
> > > > > ======================================================
> > > > >
> > > > >
> > > > >
> > > >
> > > >
> > > >__________________________________________________
> > > >Do You Yahoo!?
> > > >Yahoo! - Official partner of 2002 FIFA World Cup
> > > >http://fifaworldcup.yahoo.com
> > >
> > > Michael G. Southwell =================================
> > > DNEBA Enterprises
> > > 81 South Road
> > > Bloomingdale, NJ 07403-1425
> > > 973/492-7873 (voice and fax)
> > > southwell at dneba.com
> > > http://www.dneba.com
> > > ======================================================
> > >
> > >
> > >
> >
> >
> >__________________________________________________
> >Do You Yahoo!?
> >Yahoo! - Official partner of 2002 FIFA World Cup
> >http://fifaworldcup.yahoo.com
> 
> Michael G. Southwell =================================
> 81 South Road
> Bloomingdale, NJ 07403-1419
> 973-838-1022 (voice) 973-492-7873 (fax)
> mailto:MSouthwell at bigfoot.com
> http://www.dneba.com
> ======================================================
> 
> 
> 


__________________________________________________
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com



More information about the talk mailing list