On Wednesday, April 24, 2002, at 02:59  PM, Julio Nobrega Trabalhando 

>   I have a simple function that returns a message:
> function showError ($mensagem)
> {
>     return '<div class="erro">' . $mensagem . '</div>';
> }
>   And this is how I use it:
> if (isset($_SESSION['forum']['error']['insert'])) {
>     echo showError($_SESSION['forum']['error']['insert']));
> }
>   But I want that when the function is used the session variable is
> destroyed. A simple unset($mensagem) inside showError() gives me back 
> this:
> Warning: Undefined variable: mensagem in
> c:\www\lib\sistema\formularios\formularios.inc.php on line 92

The problem is that there is no variable called $mensagem in your 
function.  You are using a reference to something else with the name 
$mensagem, but you are not passing the value by reference -- try this:

function showError(&$mensagem)
// note the '&' before $mensagem
        return '<div class="erro">' . $mensagem . '</div>';

And let me know if that works or doesn't work.  (It's kind of a hunch, 
hard to tell from your code if it will work.)



Erik Price
Web Developer Temp
Media Lab, H.H. Brown

PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to