I am getting an error message:
Line 14 is this line:Fatal error: Call to a member function load() on a non-object in /home/content/u/l/s/56546/html/myName/SiteEditor/xmlDOMDocHandler.php on line 14
Full Code of file xmlDOMDocHandler.php:Code:$doc->load($configFilePath);
The above file is being included in another file called index.php within an If..Statement. I didn't understand the error message so I was playing around with the code trying to get it to work, that's why it may seem as if I just complicated it too much... (e.g. I don't really need the $skip variable and a few other things)..Code:<?php $skip = true; $user=""; if(isset($_SESSION['loggedOn']) && $_SESSION['loggedOn'] == "true"){ $skip = false; $user=$_SESSION['username']; } $configFilePath = 'users/'.$user.'/config.xml' . rand(1,10000); $doc = new DOMDocument(); $doc->preserveWhiteSpace = false; //Functions------------------------------------------ function loadXML(){ if($skip){return;} $doc->load($configFilePath); } function setSiteName($newName){ if($skip){return;} loadXML(); $doc->getElementsByTagName('websitename')->nodeValue = $newName; $doc->save($configFilePath); } function getSiteName(){ if($skip){return;} loadXML(); return $doc->getElementsByTagName('websitename')->nodeValue; } loadXML(); ?>
Why am I getting the error message? When I tried replacing this code:
withCode:$doc = new DOMDocument();
it worked... except the next function, the $doc->getElementsByTagName... returned the same error message.. It's like the method doesn't exist, except I know it exists, I've used it before.Code:$doc = DOMDocument::load($configFilePath);




Reply With Quote