Solved

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

Posted on 2004-09-06
6
1,623 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
SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

 

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
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…

751 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