cyb0rg51
09-28-2005, 01:49 PM
This code works on my own computer, but when applied to my webserver it gives me the error, "Call to a member function on a non-object on line 16".
I am assuming that when tested on my computer with PHP >=4.3 the variable $image is treated as an oject. However when applied to my webserver with PHP 4.3.11 the variable $image seems to be treated as an array?? Any help at all would be great.
<?php
//loads the XML file
$xmlPath = dirname(__FILE__) . "/";
$xmldoc = domxml_open_file($xmlPath . "gallery_tree.xml");
//Set root node "tree"
$root = $xmldoc -> document_element();
//Gets all the "image"s
$images = $xmldoc -> get_elements_by_tagname("image");
foreach($images as $image)
//The newly created node
$mynode = $xmldoc -> create_element("image");
$mynode -> set_attribute("label", "label test");
$mynode -> set_attribute("src", "location test");
//Assign Parent Node (folder)
$parent = $image -> parent_node();
$parent -> append_child($mynode);
echo $xmldoc -> dump_mem();
?>
I am assuming that when tested on my computer with PHP >=4.3 the variable $image is treated as an oject. However when applied to my webserver with PHP 4.3.11 the variable $image seems to be treated as an array?? Any help at all would be great.
<?php
//loads the XML file
$xmlPath = dirname(__FILE__) . "/";
$xmldoc = domxml_open_file($xmlPath . "gallery_tree.xml");
//Set root node "tree"
$root = $xmldoc -> document_element();
//Gets all the "image"s
$images = $xmldoc -> get_elements_by_tagname("image");
foreach($images as $image)
//The newly created node
$mynode = $xmldoc -> create_element("image");
$mynode -> set_attribute("label", "label test");
$mynode -> set_attribute("src", "location test");
//Assign Parent Node (folder)
$parent = $image -> parent_node();
$parent -> append_child($mynode);
echo $xmldoc -> dump_mem();
?>