Don't you already update the companion and delete the item in your existing functions???? The error has nothing to do with my code. I'm starting to think you removed your function and replaced with just my if statement -- all my code does is transform an old companion, if such a thing exists, into an item again.
PHP Code:
function items_companion($item, $adopt){
$mysidia = Registry::get("mysidia");
//MY CODE
if ($adopt->getCompanion() != "nocompanion") {
$item = new StockItem($adopt->getCompanion());
$item->append(1, $mysidia->user->username);
}
//WITH YOURS
$companion = $item->itemname;
$mysidia->db->update("owned_adoptables", array("companion" => $companion), "aid ='{$adopt->aid}' and owner='{$item->owner}'");
$note = "You have given your pet a <b>{$item->itemname}</b>! It will now show up in your pet's profile. ";
//Update item quantity...
$delitem = $item->remove();
return $note;
}
Try that?