# My Php Code Give Some Strange Problems

**URL:** <https://www.phphelp.com/t/my-php-code-give-some-strange-problems/19028>\
**Category:** PHP Installation and Configuration\
**Created:** [December 1, 2012, 6:23pm UTC](https://www.phphelp.com/t/my-php-code-give-some-strange-problems/19028 "2012-12-01T18:23:43Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mrbagino](https://www.phphelp.com/letter_avatar_proxy/v4/letter/m/da6949/32.png) [@Mrbagino](https://www.phphelp.com/u/Mrbagino)\
**Post date:** [December 1, 2012, 6:23pm UTC](https://www.phphelp.com/t/my-php-code-give-some-strange-problems/19028/1 "2012-12-01T18:23:43Z")

</div>

Dear all,

I have some problem with my php code i try to make some XML and PHP Content managmant system, but i have now some problem with the root?

He give the next error: Fatal error: Call to a member function root() on a non-object in /home/…/public\_html/searchArticles.php on line 29

See here my code please:

[php]

\<?php session\_start(); $results = array(); //this is a very simple, potentially very slow search function extractText($array){ if(count($array) \<= 1){ //we only have one tag to process! for ($i = 0; $iget\_content(); } return $value; } } $dh = opendir('./xml/'); while ($file = readdir($dh)){ if (eregi("^\\.\\.?$", $file)) { continue; } $open = "./xml/".$file; $xml = "domxml\_open\_file" .$open; //we need to pull out all the things from this file that we will need to //build our links $root = $xml-\>root("id"); $id = $root-\>get\_attribute("id"); $stat\_array = $root-\>get\_elements\_by\_tagname("status"); $status = extractText($stat\_array); $k\_array = $root-\>get\_elements\_by\_tagname("keywords"); $keywords = extractText($k\_array); $h\_array = $root-\>get\_elements\_by\_tagname("headline"); $headline = extractText($h\_array); $ab\_array = $root-\>get\_elements\_by\_tagname("abstract"); $abstract = extractText($ab\_array); if ($status != "live"){ continue; } if (eregi($searchTerm, $keywords) or eregi($searchTerm,$headline)){ $list['abstract'] = $abstract; $list['headline'] = $headline; $list['file'] = $file; $results[] = $list; } } $results = array\_unique($results); ?\>
# Search Results
back to main

You searched for: _\<?php echo $searchTerm ?\>_

* * *
\<?php if (count($results)\>0){ echo "

Your search results:

"; foreach ($results as $key =\> $listing){ echo "  
" . $listing["headline"]."\n"; echo "  
". $listing["abstract"]; echo "  
"; } } else { echo "

Sorry, no articles matched your search term.

"; } ?\>

[/php]

I hope for some sugestions, Thanks a lot!
