Solved

I tried to use DOMElement::createElement(I have already installed php5.0.1

Posted on 2004-09-06
6
1,629 Views
Last Modified: 2012-06-27
Please Help
I tried to use DOMElement::createElement(I have already installed php5.0.1
Fatal error: Call to undefined method DOMElement::createElement():
bellow is my code
<?php
$temp1 = $_POST['usernameI'];
$temp2 = $_POST['nameI'];
$temp3 = $_POST['passwordI'];

$doc = DOMDOcument::load("userdb.xml");
$newuser = $doc->CreateElement("user");

$name = $newuser->createElement("name");
$username = $newuser->createElement("username");
$password = $newuser->createElement("password");




$name->createTextNode($temp1);
$username->createTextNode($temp2);
$password->createTextNode($temp3);




?>
0
Comment
Question by:questionphpk
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 25

Expert Comment

by:Marcus Bointon
ID: 11995091
Looks like the static function you called (DOMDocument::load - check the capitalisation) is not returning you a DOM object for some reason, e.g. perhaps it can't find userdb.xml. I suggest you check the contents of $doc  to check that it is a valid instance of a DOM object. var_dump($doc) will show you what's there. The user notes on this page suggest ways of checking for errors:

http://www.php.net/manual/en/function.dom-domdocument-load.php
0
 

Author Comment

by:questionphpk
ID: 11998409
I am sure my code is fine to load xml file loading file,
The problem as I mentioned

Fatal error: Call to undefined method DOMElement::createElement():

ALready installed php5.0.1, If possible please tell me what library I need to install so that DOMElement::createElement(): will be recognized.
Thanks.
0
 
LVL 25

Expert Comment

by:Marcus Bointon
ID: 11998588
This was my point. Your example code can't tell you that this is so. If the DOM library was not installed, you would get an error on your load call because that's form the same library, therefore, you do already have the DOM library installed and working. Check the return value of DOMDocument::load before you try and use it. Like in the example I pointed you at:

$doc = DOMDOcument::load("userdb.xml");
if (!$doc) {
  print "Error creating DOM instance";
  exit;
}

Try that first, and if it still doesn't work, start investigating further.
0
WordPress Tutorial 1: Installation & Setup

WordPress is a very popular option for running your web site and can be used to get your content online quickly for the world to see. This guide will walk you through installing the WordPress server software and the initial setup process.

 

Author Comment

by:questionphpk
ID: 12000823
Sorry,
I stated the question inefficiently,
->I already know that I do not have DOM Library installed.
 and I agrree my code does not check it.
->I am very new with  PHP. PLEASE, tell me step by step
how to install DOM LIBRARY for wondow XP professional version.
Thanks,
Squinky.
0
 
LVL 25

Accepted Solution

by:
Marcus Bointon earned 500 total points
ID: 12000969
Mainly you need to put the php_domxml.dll in your PHP/extensions directory. For more detail, read this:

http://www.php.net/manual/en/install.windows.extensions.php
0
 

Author Comment

by:questionphpk
ID: 12153421
THanks
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this. Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it i…
This article discusses four methods for overlaying images in a container on a web page
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question