undefined offset 0
Fri, 05/15/2009 - 16:33
Hi,
I am trying to debug this and I keep getting an error in line 24.
I am guessing that the ReferalArray doesn't exist, that Line 21 is creating NULL.
Is there a way that I can do a check before Line24 if it exists and otherwise assign a default value or skip the section altogether?
Thanks.
Line 19: $this->objUser = unserialize($_SESSION['User']);
Line 20:
Line 21: $ReferalArray = User::LoadArrayByUserAsAllies($this->objUser->Id);
Line 22:
Line 23: $this->lblReferal = new QLabel($this);
Line 24: $this->lblReferal->Text = $ReferalArray[0]->FullName;
Hi,
You can do it like this:
$ReferalArray = User::LoadArrayByUserAsAllies($this->objUser->Id);
$this->lblReferal = new QLabel($this);
if ($ReferalArray) {
$this->lblReferal->Text = $ReferalArray[0]->FullName;
} else {
$this->lblReferal->Text = "Some default";
}