Page 1 of 1

Multiple function parameters problem

Posted: Fri Nov 16, 2007 11:07 am
by RobbieL
feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


Evening all,

I'm trying to create a message centre, where users can sendand receive messages to each other, but I've hit a snag. I've got a three functions. Lets call them function a, function b and function c. Function B and C contain a variable each, which A needs to read. So in the parameters of function A I put in each variable. However, this spat an error out because the variables had not yet been created in function B and C since function A is the first to run. So, to try and combat that, I did the following:

Code: Select all

function index($messageSent = FALSE, $deleteConfirm = FALSE)
	{
		if(!isset($_SESSION['MM_Username']))
		{
			echo 'Hello';
		}
			
		if(isset($messageSent) && $messageSent == TRUE)
		{
			$data['messageSent'] = 'yes';
		}
		
		if(isset($deleteConfirm) && $deleteConfirm == TRUE)
		{
			$data['deleteConfirm'] = 'yes';
		}
Now, on my HTML page I put:

Code: Select all

<? if(isset($messageSent) && $messageSent == TRUE)
				{?>
                	<p>Message has been sent</p>
                <?
				}
                elseif(isset($deleteConfirm) && $deleteConfirm == TRUE)
				{?>
                	<p>Messages have been deleted</p>
                <?
				}?>
Now I don't get any errors, but after I send a message or delete a message, it will always show the "Message has been sent" alert ... as if it can only read the first part of the if.

Anyone any ideas?


feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Fri Nov 16, 2007 10:15 pm
by RobertGonzalez
Function B and C contain, produce, read or create the variable that function A needs?

Posted: Sat Nov 17, 2007 3:07 am
by RobbieL
Ah, that's it! Big thanks, Everah!

Posted: Sat Nov 17, 2007 8:19 am
by RobertGonzalez
So did you figure it out?