ich betreibe mein gästebuch mit xml und verwende dafür SimpleXML.
Das Lesen funktioniert. Das Schreiben geht nicht.
Sobald ich mit asXML() speichern will kommt der Fehler:
Fatal error: Cannot access empty property in (Path/to/dir)/guestbook.php on line 36
hier die guestbook.php mit der engine klasse
	
Was mache ich falsch oder was muss ich ändern?
							
						
					Das Lesen funktioniert. Das Schreiben geht nicht.
Sobald ich mit asXML() speichern will kommt der Fehler:
Fatal error: Cannot access empty property in (Path/to/dir)/guestbook.php on line 36
hier die guestbook.php mit der engine klasse
PHP Code:
	
	
class GuestbookEngine {
    var $oXml = null;
    function isNull() {
        return ($this->oXml == null);
    }
    
    function GuestbookEngine($file) {
        $this->oXml = simplexml_load_file($file);
    }
    
    function getAllEntries() {
        return $this->oXml->xpath("/guestbook/entry");
    }
    
    function getEntriesWithName($name) {
        $results = array();
        foreach($this->getAllEntries() as $entry) {
            if($entry["name"] == $name) {
                $results[] = $entry;
            }
        }
        return $results;
    }
    
    function getEntryCount() {
        return count($this->getAllEntries());
    }
    function addEntry($name,$time,$text) {
        $child = $this->oXml->addChild('entry');
        $child->addChild('name','<![CDATA['.$name.']]>');
        $child->addChild('time',$time);
        $child->addChild('text','<![CDATA['.$text.']]>');
    }
    function saveAsFile($file) {
        $this->$oXml->asXML($file); // <--- Zeile 36
    }
} 
							
						
          
 Moderator
							
						

 
  hab ich übersehen.
							
						
Comment