Page 1 of 1

Function Question

Posted: Sun Jan 26, 2003 11:12 pm
by smoky989
OK I have a form for people to change their bio information. It works fine. I ran into a problem when I tried to have the changes mailed to me.

What I'm doing is creating a variable called $changes, I send the original value and the new value of the variable being changed whether it be name or email or whatever. I have a variable named $c for the category being changed.

I call the function as so

$changes = $changes.check_change( $field, $oldvar, $newvar);

My function is as follows

function check_change($c, $oldvar, $newvar)
{
if ($oldvar != $newvar)
{
echo "\n'$c' was changed from '$oldvar' to '$newvar'.";
}
}

The echo part works great but the variable is not contatenating the way I thought it would.

I have to run the function for about 10 variables and I want the end $changes variable to have all the changes made. Any ideas what my problem is? Thanks to anyone looking at this. The help is appreciated.

Posted: Sun Jan 26, 2003 11:41 pm
by Stoker
Seems like you mixed up the sequence of variables in your call and the function it self..

try chaning the function call to

check_change($field, $oldvar, $newvar);

Posted: Sun Jan 26, 2003 11:53 pm
by smoky989
In my post I had it right, I just copied it wrong here. I edited my post though. The code above is the exact code im using and it wont work

Posted: Mon Jan 27, 2003 12:03 am
by Stoker
Your function doesn't return anything, it just echoes.. either you want to replace echo with return (in the function) or add another line that does return instead of echo..

In the words of Chris Farley...

Posted: Mon Jan 27, 2003 12:43 am
by smoky989
In the words of Chris Farley, "Son of a..." Thanks man, that fixed my problem.