Re: arrays, variables, and register_globals

From: Date: Thu, 25 Jul 2002 05:48:09 +0000
Subject: Re: arrays, variables, and register_globals
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-20772@lists.php.net to get a copy of this message
In article <8CD183325ADED411AEAD00034708D0B9A94506@mail.gc.cuny.edu>, MGOLD1@gc.cuny.edu says... > I developed my site on a server where register_globals was off; now I'm > putting the site up on a server where they are on. > > I know how to echo the value of a variable that is passed in the > querystring, but I'm having trouble echoing the value of a variable that is > in my select statement--I can get the value when it is in a while loop, but > outside of that I'm having trouble: > > $query = "Select blah1, blah2, blah3 from blahtable"; > $result = mysql_query ($query) > or die ("Cannot complete query"); > > print "$row[1]"; // this is the kind of thing that is not working...I > tried get_defined_vars() but may not have used it correctly > > while ($row = mysql_fetch_row ($result)) > { > print "$row[1], $row[2], etc."); > } > > ?> > > In the above example, the variables in the while loop get expanded, but the > one outside doesn't.... > > Can anyone help? > > thanks in advance, > > Matt In the first case, $row[1] doesn't exist; so of course it will not show anything. The array $row doesn't get any contents until you assign the values from mysql_fetch_row to it. -- David Robley Temporary Kiwi! Quod subigo farinam

« previous php.db (#20772) next »