Re: What's wrong with my function? :(

From: Date: Wed, 31 Oct 2001 15:42:10 +0000
Subject: Re: What's wrong with my function? :(
References: 1 2  Groups: php.db 
Request: Send a blank email to php-db+get-13885@lists.php.net to get a copy of this message
Tx. Yep I have read it now and understood it better than the first time I read this part of the manual (it's amazing how things make more sense when you can apply them to what you are doing). "Jesse Goerz" <jgoerz@bellsouth.net> wrote in message news:01103017270000.19453@reign... > On Tuesday 30 October 2001 15:49, TorrentUK wrote: > > Please could some take a look at this code and tell me why > > when I take my IF statements out of the function and put in > > them in the same place where I call the function from they > > work, but as soon as I replace them with the function name > > they don't? > > > > Appreciate any help. > > torrent > > > > Here's the code... > > Your variable is not in scope. Either pass your variable as a > reference in the function definition: > function RatingFilter (&$sql) { > ... > } > > or use the global keyword to bring your variable into scope: > function RatingFilter () { > global $sql; > if ($br) {$sql.= " and beg_rate >= '2'";} > ... > } > > And follow the advice of Charles and read up on it so you know > how they are different. >

« previous php.db (#13885) next »