note 76673 added to function.simplexml-load-file
| From: | paul at christianpatriot dot us | Date: | Wed, 25 Jul 2007 16:16:36 +0000 |
| Subject: | note 76673 added to function.simplexml-load-file | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-128922@lists.php.net to get a copy of this message | ||
Attempting to append child/attributes to an existing xml file using
post data from an html form. Post data gets passed fine, but it seems
the xml file is never opened or loaded.
Since I don't think the file is ever opened, I am unable to (attempt
to) write the new data to the file. The script returns no errors but doesn't access the
gbook.xml which has all permissions granted to everyone.
HELP PLEASE, it looks so simple :-) in the manual.
Reproduce code:
---------------
processgb.php
<?php
if (file_exists('gbook.xml')) {
$xml = simplexml_load_file('gbook.xml');
} else {
exit('Failed to open gbook.xml.');
}
$entry=$xml->addChild('entry');
$entry->addAttribute('date',date("Y-m-d"));
$entry->addChild('name',$_POST["name"]);
$entry->addChild('email',$_POST["email"]);
$entry->addChild('homepage',$_POST["homepage"]);
$entry->addChild('country',$_POST["country"]);
$entry->addChild('comment',$_POST["comment"]);
$result=file_put_contents($xml,"gbook.xml"); if ($result<1 or
result==false): echo 'error writing: '.$result;
endif;
?>
XML structure:
<?xml version="1.0" encoding="utf-8" ?>
<guestbook>
<entry date="">
<name></name>
<email></email>
<homepage></homepage>
<country></country>
<comment></comment>
</entry>
</guestbook>
----
Server IP: 64.71.164.2
Probable Submitter: 68.213.142.108
----
Manual Page -- http://www.php.net/manual/en/function.simplexml-load-file.php
Edit -- https://master.php.net/note/edit/76673
Del: integrated -- https://master.php.net/note/delete/76673/integrated
Del: useless -- https://master.php.net/note/delete/76673/useless
Del: bad code -- https://master.php.net/note/delete/76673/bad+code
Del: spam -- https://master.php.net/note/delete/76673/spam
Del: non-english -- https://master.php.net/note/delete/76673/non-english
Del: in docs -- https://master.php.net/note/delete/76673/in+docs
Del: other reasons-- https://master.php.net/note/delete/76673
Reject -- https://master.php.net/note/reject/76673
Search -- https://master.php.net/manage/user-notes.php