Re: What's wrong with my function? :(
| From: | Jesse Goerz | Date: | Tue, 30 Oct 2001 22:27:00 +0000 |
| Subject: | Re: What's wrong with my function? :( | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-13873@lists.php.net to get a copy of this message | ||
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.