如果没有PHP Mailer

I am trying to send a different email to users after the confirmation of registration. One will be for admin users and the other text will be for basic users. I wrote and if else statement based on queried data but its sending both emails to both types of users. Any idea what is wrong?

function SendBusWelcomeEmail(&$user_rec)
    {
 $result = mysql_query("SELECT business FROM users")
               or die(mysql_error());


if($result='a') {
        $mailer = new PHPMailer();

        $mailer->CharSet = 'utf-8';

        $mailer->AddAddress($user_rec['email'],$user_rec['name']);

        $mailer->Subject = "Welcome to ".$this->sitename;

        $mailer->From = $this->GetFromAddress();        

        $mailer->Body ="Thank You ".$user_rec['name']." for joining xxx, 

".
        "We are a brand new business with big ambitions. Our mission is to help the development of your skills 
".

        "
".
        "Regards,
".
        "Webmaster
".
        $this->sitename;
}
        if(!$mailer->Send())
        {
            $this->HandleError("Failed sending user welcome email.");
            return false;
        }
        else{
        $mailer = new PHPMailer();

        $mailer->CharSet = 'utf-8';

        $mailer->AddAddress($user_rec['email'],$user_rec['name']);

        $mailer->Subject = "Welcome to ".$this->sitename;

        $mailer->From = $this->GetFromAddress();        

        $mailer->Body ="Hello ".$user_rec['name']."

".
        "Welcome! Your registration  with ".$this->sitename." is completed.
".
        "
".
        "Regards,
".
        "Webmaster
".
        $this->sitename;

        if(!$mailer->Send())
        {
            $this->HandleError("Failed sending user welcome email.");
            return false;
        }
}
    }

In your condtion it should be == rather than =.

So change

if($result = 'a')

to

if($result == 'a')

Note: You are not fetching the record. And It seems that your query must contain a where condition to get business type of user. Not sure though.

Tip: Why don't you get your common code out of the both condition & just change the mail body content depending on the condition.

after this line

$result = mysql_query("SELECT business FROM users") or die(mysql_error());

use for fetching the result.

$result = mysql_fetch_array($result);