Function Question

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
smoky989
Forum Commoner
Posts: 41
Joined: Mon Sep 02, 2002 1:14 pm

Function Question

Post 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.
Last edited by smoky989 on Sun Jan 26, 2003 11:51 pm, edited 1 time in total.
User avatar
Stoker
Forum Regular
Posts: 782
Joined: Thu Jan 23, 2003 9:45 pm
Location: SWNY
Contact:

Post 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);
smoky989
Forum Commoner
Posts: 41
Joined: Mon Sep 02, 2002 1:14 pm

Post 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
User avatar
Stoker
Forum Regular
Posts: 782
Joined: Thu Jan 23, 2003 9:45 pm
Location: SWNY
Contact:

Post 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..
smoky989
Forum Commoner
Posts: 41
Joined: Mon Sep 02, 2002 1:14 pm

In the words of Chris Farley...

Post by smoky989 »

In the words of Chris Farley, "Son of a..." Thanks man, that fixed my problem.
Post Reply