Hello Everyone,
I keep getting the following errors in my class and I don't know why. Maybe
something has changed in PHP 5.x that I don't know about? Here are the
errors and the methods of that class:
-----------------------
Notice: Undefined index: 0 in
L:\localhost\catalog\catalog_0.1.0\includes\classes\tree.class.php on line
77
Notice: Undefined index: 0 in
L:\localhost\catalog\catalog_0.1.0\includes\classes\tree.class.php on line
77
Fatal error: Cannot use object of type DB_Error as array in
L:\localhost\catalog\catalog_0.1.0\includes\classes\tree.class.php on line
46
-----------------------
Line 77 is the 5th line of the following function:
-----------------------
function get_ancestors($child) {
// get child's lft & rgt values
$data = $this->get_cat_coord($child);
// get ancestors of child based on child's lft and rgt values
$tree = $this->fetch('SELECT * FROM tree WHERE lft <
'.$data['0']['lft'].' AND rgt > '.$data['0']['rgt'].' ORDER BY lft ASC');
return $tree;
}
-----------------------
Line 46 is the 3rd line of the following function
-----------------------
function get_parent($child) {
$parent = $this->get_ancestors($child);
$parent = $parent[count($parent)-1];
if (count($parent) > 0) {
return $parent;
} else {
return 0;
}
}
-----------------------
I am calling the following function which calls the other two child
functions above:
-----------------------
function add_cat($cat, $addAfterCat_name='', $addAfterCat_lft='') {
if (!$this->exists_in_category($cat, $addAfterCat_name)) {
$db = $this->dbconnect();
if ($cat != '' && $addAfterCat_lft != '') {
$db->query("UPDATE tree SET rgt=rgt+2 WHERE
rgt>".$addAfterCat_lft);
$db->query("UPDATE tree SET lft=lft+2 WHERE
lft>".$addAfterCat_lft);
$add_query = "INSERT INTO tree SET lft='";
$add_query .= $addAfterCat_lft+1;
$add_query .= "', rgt='";
$add_query .= $addAfterCat_lft+2;
$add_query .= "', category='$cat'";
echo $add_query;
$db->query($add_query);
$message = 'Category Added To Tree';
} elseif ($cat != '' && $addAfterCat_lft == '') {
$message = 'Please Input A Category To Add';
} elseif ($cat == '' && $addAfterCat_lft != '') {
$message = 'Please Choose A Category To Add This Category
To';
}
} else {
$message = 'Category Already Exists In The Parent Category';
}
return $message;
}
-----------------------
What am I doing wrong?
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php