I get the following error when I try to pass a value to a methiod in a loop:
Warning: Attempt to assign property of non-object in /Users/staceyschaller/Sites/dev_zone/ckwv2/classes/class.php on line 670
This one has me very baffled. It will work the first time, and seems to work every other time, so I have no clue what is wrong. Here is the code:
This code is part of my "display" class:
function display_partner ($type,$loc,$rand=0,$narrow=0) {
$this->partners = new partner($this->cxn);
$display = '
<div id="cont_info" class="partner-list">
<div>
<h3 class="settings">'.ucfirst($loc).' '.ucfirst($type).last_letter($type).'s</h3>
</div>
<div class="settings-value" style="height:12px;padding:0;margin:0;text-align:right;padding-right:10px;">
<a href="" class="trunc">Add your organization to this list</a></p>
</div>
<div style="height:2px;padding:0;margin:0;">
<hr class="account" />
</div>
';
$ids = $this->partners->get_partners_list($type,$loc,$rand);
for ($b=0;$b<sizeof($ids->id);$b++) {
$this->partnerID = $ids->id[$b];
$display .= ($narrow)? $this->card_partner_narr():$this->card_partner();
if ($b!=(sizeof($ids->id)-1)) { $display .= '<hr class="account" />'; }
}
if (sizeof($ids->id)==0) {
$display .= '<div style="color:#999999;display:line;text-align:center;height:20px;">No Partners found for '.ucfirst($loc).' '.ucfirst($type).'</div>';
}
$display .= '
</div>';
return $display;
}
function card_partner () {
$this->partners->set_partner_id($this->partnerID);
$part_info = $this->partners->get_partner_info();
if ($part_info) {
$display .= '
<table class="settings">
<tr>
'.$this->show_if($part_info['partLogo']['val'],'<td class="settings-value" rowspan="2"><img src="'.LOGO_FOLDER.$part_info['partLogo']['val'].'" '.resize_img(LOGO_FOLDER.$part_info['partLogo']['val'],175).'alt="'.$part_info['partName']['val'].'" /></td>').'
<td class="settings-value" colspan="2"><h5>'.$part_info['partName']['val'].'</h5></td>
</tr>
<tr>
<td class="settings-value">
<span style="color:999999;">'.$part_info['partAddress']['val'].'<br />
'.$part_info['partCity']['val'].', '.$part_info['partST']['val'].' '.$part_info['partZIP']['val'].'<br />
'.$part_info['partPhone']['val'].'</span><br />
<a href="'.$this->form->show_href($part_info['partWeb']['val']).'" target="_blank">'.$part_info['partWeb']['val'].'</a>
</td>
<td class="settings-value">'.$part_info['partInfo']['val'].'</td>
</tr>
</table>
';
}
return $display;
}
This code is part of my "partners" class:
function set_partner_id($partID) {
echo '<p>partID: '.$partID.' '.gettype($partID).'<br>
$this->partner->id: '.$this->partner->id.'</p>';
$this->partner->id = $partID; ///*** ERROR HAPPENS HERE ***/
echo '<p>id set: '.$this->partner->id.'<br>
$this->partner->id: '.$this->partner->id.'</p><hr>';
}
function get_partner_id() {
return $this->partner->id;
}
// gets user info at login
function get_partner_info() {
$this->partner = $this->cxn->proc_info('partner','partID',$this->partner->id);//$this->partner->id
return $this->partner;
}
The following is the output generated:
partID: 24 string
$this->partner->id:
id set: 24
$this->partner->id: 24
partID: 26 string
$this->partner->id:
Warning: Attempt to assign property of non-object in /Users/staceyschaller/Sites/dev_zone/ckwv2/classes/class.php on line 670
id set:
$this->partner->id:
partID: 17 string
$this->partner->id:
id set: 17
$this->partner->id: 17
partID: 25 string
$this->partner->id:
Warning: Attempt to assign property of non-object in /Users/staceyschaller/Sites/dev_zone/ckwv2/classes/class.php on line 670
id set:
$this->partner->id:
As you can see, the value passes to $this->set_partner_id($partID) each time. It is formatted as a string. When it assigns the value to $this->partner->id, however, sometimes it works, and sometimes it doesn't. It's probably something obvious, but I've racked my brain to see what it is. Any ideas?