Solved

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

Posted on 2004-09-06
6
1,620 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
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!

 

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

Suggested Solutions

Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

740 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