Email doesn't send based on variable name
<p>My email will only send if I type in the actual address rather than using $usr_email, although it says 'message sent'. The Email address comes from the user_email field in users table.
This is defined with 
    $id = intval($_SESSION['user_id']);</p>

<pre><code>if (isset($_POST['doSend'])) {


function getTwo($query){
    $res = mysql_query($query);
    if (!$res) {
        trigger_error("db: ".mysql_error()." in ".$query);
        return FALSE;
    }
    if ($row = mysql_fetch_row($res)) {
        return $row[0];
    }
}

$getuserinfo_q = "SELECT user_email AND user_name FROM users WHERE 
id='$_SESSION[user_id]'";

$getuserinfo_e=mysql_query($getuserinfo_q);

if(mysql_num_rows($getuserinfo_e) &lt; 1){

    echo "User details not found - User_id is not in DB";

    exit();

}

$user_info_val=mysql_fetch_assoc($getuserinfo_e);

if(empty($user_info_val['user_email'])){

    echo "there is no such column name as 'user_email'"; //tell the user about column

    exit(); //shut off the script

}


$usr_email=$user_info_val['user_email'];
  $user_name=$user_info_val['user_name'];



$sqltest = "SELECT completed_status From users where id =
'$_SESSION[user_id]'";
$isSending = getTwo($sqltest);
$isSending === false;
if($isSending &gt;= 6){
    require_once "Mail.php";
    require_once "Mail.php";



    $from = "&lt;xxx&gt;";
    $to = "$usr_email";
    $subject = "hi";
$body ="Chi ";

$host = "ssl://smtp.gmail.com";
$port = "465";
    $username = "xxx";
    $password = "xxxx";

 $headers = array ('From' =&gt; $from,
'To' =&gt; $to,
'Subject' =&gt; $subject);
$smtp = Mail::factory('smtp',
array ('host' =&gt; $host,
    'port' =&gt; $port,
    'auth' =&gt; true,
    'username' =&gt; $username,
    'password' =&gt; $password));

$mail = $smtp-&gt;send($to, $headers, $body);

    if (PEAR::isError($mail)) {
        echo("&lt;p&gt;" . $mail-&gt;getMessage() . "&lt;/p&gt;");
    } else {
        echo("&lt;p&gt;Message successfully sent!&lt;/p&gt;");
    }
}
else
    header ("Location: error.php");



}
</code></pre>
