Hey guys,
im trying to do a simplexml_load_file and it is giving me this error...(PHP Fatal error: Call to a member function asXML() on a non-object)..my xml code is pretty basic so im not sure what is going wrong. here is the code
<?php
//$mid = mysql_insert_id();
//$mq = mysql_query("SELECT * FROM updates WHERE userid='".$userid."' AND id='".$mid."'");
//$mrow = mysql_fetch_assoc($mq);
//$mpath = $mrow['musicpath'];
$filename = "/var/www/members/1/playlist.xml";
$xml = simplexml_load_file($filename);
$sxe = new SimpleXMLElement($xml->asXML());
$track = $sxe->addChild("track");
$track->addChild("location", "test");
$track->addChild("title", "test");
echo "<br />";
$sxe->asXML("/var/www/members/1/playlist.xml");
?>
PHP Fatal error: Call to a member function asXML() on a non
Moderator: General Moderators
Re: PHP Fatal error: Call to a member function asXML() on a
The error message indicates that either $xml or $sxe is not an object, so simplexml_load_file() might have returned something other than an object. The documentation says that the function returns FALSE if an error occurred. The error may be a result of improperly-formatted XML, a non-existent file, or restrictive file permissions.
Enable error_reporting and display_errors directives. Also, see Dealing with XML errors.
Enable error_reporting and display_errors directives. Also, see Dealing with XML errors.
Re: PHP Fatal error: Call to a member function asXML() on a
it was the file permissions. I had to grant www-data write access to the file. Thank you for your reply I appreciate it.