Jump to content

[SOLVED] Returning a variable


Kemik

Recommended Posts

Hello all,

 

If I make a database query in one function and return the variable.

 

E.g.

<?php

$q = "SELECT email FROM ".TBL_USERS." WHERE username = '$username'";
$result = mysql_query($q, $this->connection);
$dbarray = mysql_fetch_array($result);
$email = $dbarray['email'];
return $email;
?>

 

I can then use that variable when calling the function cannot I?

 

E.g.

<?php

if ($database->getEmail($username)){

$mailer->sendJoin($this->username, $email);
return 0;  //New user added succesfully

} ?>

 

The only problem is, the script isn't sending the $email variable to the $mailer. It sends the username fine, but the $email is blank. I've tried making an echo in the second set of code I showed you and $email is empty.

Link to comment
https://forums.phpfreaks.com/topic/62377-solved-returning-a-variable/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.