Solved

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

Posted on 2004-09-06
6
1,602 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:Squinky
Comment Utility
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
Comment Utility
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:Squinky
Comment Utility
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
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 

Author Comment

by:questionphpk
Comment Utility
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:
Squinky earned 500 total points
Comment Utility
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
Comment Utility
THanks
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Consider the following scenario: You are working on a website and make something great - something that lets the server work with information submitted by your users. This could be anything, from a simple guestbook to a e-Money solution. But what…
This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to count occurrences of each item in an array.

728 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now