XML DOM Error

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jeremy1987
Forum Newbie
Posts: 3
Joined: Tue Jun 12, 2007 10:57 pm

XML DOM Error

Post by jeremy1987 »

im simi new to php and ive tried everything that I can think of but i keep getting this error can someone please help me out.

Heres the error i keep getting
Fatal error: Call to undefined function: appendchild() in /uploadscript/1stupload.php on line 40

Code: Select all

<?php
error_reporting( E_ALL ); ini_set( 'display_errors', 'on' );
$uploadLocation = "images/";

   
    if (isset($_POST['submitBtn'])){



$target_path = $uploadLocation . basename( $_FILES['upfile']['name']);

if(move_uploaded_file($_FILES['upfile']['tmp_name'], $target_path)) {
    echo "The file: ".  basename( $_FILES['upfile']['name']).
    " has been uploaded!";
} 
else
{
    echo "There was an error uploading the file, please try again!";
}
            
    }

 $dom = new DOMNode('1.0'); 

///////////////////////RIGHT HERE IS THE PROBLEM ///////////////////////////////////////////////////////////
 $books = $dom->appendChild($dom->createElement("books"));
 
 $book = $books->appendChild($dom->createElement('book')); 

 $description = $book->appendChild($dom->createElement('description')); 
 
if(isset($_POST['description'])) 
$description = $_POST['description']; 
else //error

$title = $book->appendChild($dom->createElement('title'));

$title->appendChild( 
                $dom->createTextNode('description'));
 
 $dom->formatOutput = true; 
 $test = $dom->saveXML(); 
 $dom->save('test.xml');
 ?>
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post by superdezign »

The lack of a root DOMDocument object can sometimes cause read-only errors, but from the look of your situation, it's as though the DOM just isn't working. Which version of PHP do you have?
jeremy1987
Forum Newbie
Posts: 3
Joined: Tue Jun 12, 2007 10:57 pm

Post by jeremy1987 »

im using dreamweaver cs3 which has php 5.
jeremy1987
Forum Newbie
Posts: 3
Joined: Tue Jun 12, 2007 10:57 pm

Post by jeremy1987 »

bump
mrkite
Forum Contributor
Posts: 104
Joined: Tue Sep 11, 2007 4:19 am

Post by mrkite »

I've never created a DOMNode with its constructor.. didn't know it had one. I always used DomDocument->createElement

php.net doesn't show a __construct function for DOMNode.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Congratulations ~jeremy1987, you just got your thread locked for bumping it a second time in under 24 hours. This thread will be unlocked in 48 hours.

BUMPING IS NOT TOLERATED.
Post Reply