|
Posted by Peter Jay Salzman on 10/31/88 11:33
I have a very simple class: 2 variables, 3 methods. PHP is telling me that
$this is undefined in one of the functions, but is defined and has the
expected value in the other two functions.
In the code before, $this is defined in LinksClass() and navbarLinks(), but
not selectGroup(). I've never seen anything like this before. What could
possibly be causing this?
<?
require_once('classDatabase.php');
Class LinksClass
{
var $groups;
var $links;
function LinksClass()
{
$db = new DatabaseClass;
$tblLnkGrp = 'pbtbl_lnkgrp';
$tblLinks = 'pbtbl_links';
// Store linkgroups in array indexed by linkgroup id.
//
$db->query("SELECT * FROM $tblLnkGrp");
while ( $row = $db->fetchArray() )
$this->groups[$row['id']] = $row;
// Store links in array indexed by link id.
//
$db->query("SELECT * FROM $tblLinks");
while ( $row = $db->fetchArray() )
$this->links[$row['id']] = $row;
}
// Creates a select menu of the linkgroups. UNUSED
//
function selectGroup( $activeGroupId = '' )
{
echo '<pre>'; print_r($this); echo '</pre>'; exit;
$output = '<select name="lnkGrp">';
foreach ( $this->groups as $group )
{
$grpId = $group['id'];
$grpName = $group['name'];
$selected = ( $activeGroupId == $grpId ) ? 'selected="selected"' : '';
$output .= "<option value=\"$grpId\" $selected>$grpName</option>\n";
}
echo $output . '</select>';
}
function navbarLinks()
{
echo '<div id="nav-links">';
StartNavGroup();
NavGroupHeading(LINKS);
foreach ( $this->links as $lnk )
NavItem($lnk['url'], $lnk['text'], $lnk['title']);
EndNavGroup();
echo '</div> <!-- nav-links -->';
}
}
?>
Navigation:
[Reply to this message]
|