Kemik Posted July 29, 2007 Share Posted July 29, 2007 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 More sharing options...
pocobueno1388 Posted July 30, 2007 Share Posted July 30, 2007 Try storing the email in a variale. <?php if ($database->getEmail($username)){ $email = $database->getEmail($username); $mailer->sendJoin($this->username, $email); return 0; //New user added succesfully } ?> Link to comment https://forums.phpfreaks.com/topic/62377-solved-returning-a-variable/#findComment-310471 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.