0

I know this is a stupid question, but how can I get the value $mail out of this function?

function Email()
	{
		
		$the_name = $_SESSION[$this->GetLoginSessionVar()];
	
		$profil_query="SELECT * FROM $this->tablename WHERE username='$the_name'";

		$resultate_profil=mysql_query($profil_query);

		$resultat=mysql_fetch_array($resultate_profil);
		
		$mail = $resultat['email'];
	
	}

echo $mail;

Thanks.

2
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by seularts
1

using return statement at the end of function

function Email()
	{
		
		$the_name = $_SESSION[$this->GetLoginSessionVar()];
	
		$profil_query="SELECT * FROM $this->tablename WHERE username='$the_name'";

		$resultate_profil=mysql_query($profil_query);

		$resultat=mysql_fetch_array($resultate_profil);
		
		$mail = $resultat['email'];
	 
                return $mail;
	}
$revalue=Email();
echo $retvalue;

Edited by urtrivedi: n/a

Votes + Comments
useful
0

Ok, I found it, sorry for the non-useful post, but I hope I can help others that want to do this. The answer was:

function Emails($mail)
	{
		
		$the_name = $_SESSION[$this->GetLoginSessionVar()];
	
		$profil_query="SELECT * FROM $this->tablename WHERE username='$the_name'";

		$resultate_profil=mysql_query($profil_query);

		$resultat=mysql_fetch_array($resultate_profil);
		
		$mail = $resultat['email'];
		
		return($mail);
	
	}

echo Emails($mail);
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.