Page 1 of 1

XML DOM Error

Posted: Mon Sep 24, 2007 5:46 am
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');
 ?>

Posted: Mon Sep 24, 2007 6:59 am
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?

Posted: Mon Sep 24, 2007 7:15 am
by jeremy1987
im using dreamweaver cs3 which has php 5.

Posted: Mon Sep 24, 2007 8:59 pm
by jeremy1987
bump

Posted: Mon Sep 24, 2007 10:54 pm
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.

Posted: Mon Sep 24, 2007 11:32 pm
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.