Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2004-09-06
6
Medium Priority
?
1,644 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
  • 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
Independent Software Vendors: 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 1000 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

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…
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to dynamically set the form action using jQuery.
Suggested Courses

927 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