[solved]code help

what’s wrong with my code ?




                $criteria = new CDbCriteria;

                $criteria->select = 'StaffID';

                $criteria->addCondition('MainMembershipID=:introid');

                $criteria->addCondition('MemberShipID=:member');

                $criteria->addCondition('CompanyID=:compid');

                $criteria->params = array(

                  ':introid'=>$introid,

                  ':member'=>$result,

                  ':compid'=>$compid

                );

$invitedresult = Wsinvitedmember::model()->findAll($criteria)

                if(!is_null($invitedresult))

                {

                    Yii::app()->user->setFlash('joinedalready','You have joined to this company already');

                }

                if(is_null($invitedresult))

                {

                    $model3->save(false);

                    Yii::app()->user->setFlash('joined','You have sucessfully Joined');

                    $sql = "SELECT WSEmailAddress FROM wsmembers AS w, wsmemberinvites AS wi

                                WHERE w.MemberShipID = (SELECT IntroducingMemberID from wsmemberinvites WHERE IntroducingMemberID = :introid)";

                    $sql = $conn->createCommand($sql);

                    $sql->bindValue(':introid',$introid);

                    $result = $sql->queryScalar();


                    $to = $result;

                    $subject = "Invitation Accepted";

                    $message .= "Your invitation to ". $email ." was accepted<br />";

                    $headers  = 'MIME-Version: 1.0' . "\r\n";

                    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

                    $headers .= 'From: Buggyman <buggyman@gmail.com>' . "\r\n";

                    mail($to,$subject,$message,$headers);

    

                }



view




                <?php if(Yii::app()->user->hasFlash('joined')): ?>

                <script>

                alert("You have successfully joined the company, please login now");

                window.location = "http://yii/app/index.php?r=site/login";

                </script>

                <?php endif; ?>

                <?php if(Yii::app()->user->hasFlash('joinedalready')): ?>

                <script>

                alert("You already joined this company!");

                window.location = "http://yii/app/index.php?r=site/login";

                </script>

                <?php endif; ?>



it always say, “you have joined the company already” even if there isn’t any record at all,

don’t use is_null as by explained on the API findAll() returns a list of active records satisfying the specified condition OR an empty array is returned if none is found. So it is never null.

Cheers

problem solved, empty() php function used instead :lol: