Re: [PHP-DB] What's wrong with my function? :( From: Jesse Goerz (jgoerz <email protected>)
Date: 10/30/01

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.

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-db-unsubscribe <email protected>
For additional commands, e-mail: php-db-help <email protected>
To contact the list administrators, e-mail: php-list-admin <email protected>