Jump to content

[SOLVED] PHP DOM


runei

Recommended Posts

I am not sure if this is the right place to post it but here it goes. I get an error like the one under when i posted my site on freehostia server. It is working on my localhost after i enabeled the extension=php_xsl.dll file to process xml with xslt.

 

Line 25 : $dom = new DomDocument('1.0', 'UTF-16');

Line 28 : $root = $dom->createElement('Myarticles', '');

 

Warning: domdocument() expects parameter 2 to be long, string given in /home/www/.....net/articles/includes/writingDOM.php on line 25

Fatal error: Call to undefined function: createelement() in /home/www/.....net/articles/includes/writingDOM.php on line 28

 

Here is the original file

<?php

/**
* Henter id hvis den eksisterer
*/
$id = ($_GET['id']);

/**
*  For eksempelets skyld sammenlignes id i SESSION med userid(FK) i forum_topics. Her har man da tilgang på alle felt til eksisterende session(userid),
* forutsatt at session(userid) eksisterer.
*/
if ($id){
$sql = "SELECT * FROM forum_topics WHERE userid='".$_SESSION['userid']."'";
$result = mysql_query($sql) or die (mysql_error());
if (mysql_num_rows($result) == 0){
echo "You have not published any articles";
}else{


/**
* Lager et nytt xml dokument basert på hva man måtte ønske å vise i xml format fra tabellen forum_topics.
* UTF-16 må brukes ettersom UTF-8 gir feilmelding.
*/ 

$dom = new DomDocument('1.0', 'UTF-16');


$root = $dom->createElement('Myarticles', '');

        $root = $dom->appendChild($root);

        while ($row = mysql_fetch_assoc($result)) {

                $category = $dom->createElement('category', '');

                $category = $root->appendChild($category);

                $category->setAttribute('id', $row['id']);

			#
			$user = $dom->createElement('user', $row['id']);

                
                $title = $dom->createElement('title', $row['title']);

                $title = $category->appendChild($title);
                
                $message = $dom->createElement('message', $row['message']);

                $message = $category->appendChild($message);
                

        }


        $dom->save('Myarticles.xml');


}

}
?>

<?php

/**
* Laster inn xsl og xml filen. xsltprosessoren prosesserer begge slik at det er mulig å se resultatet i xhtml format i browser.
*/
$DOMxsl = new DOMDocument();

        $DOMxsl->load('Myarticles.xsl');

        $proc = new XSLTProcessor;

        $xsl = $proc->importStylesheet($DOMxsl);

        $DOMxml = new DOMDocument();

        $DOMxml->load('Myarticles.xml');

        $result = $proc->transformToXml($DOMxml);

        print $result;


?>

 

 

thx runei

 

 

Link to comment
https://forums.phpfreaks.com/topic/132316-solved-php-dom/
Share on other sites

i suggest you read the user-notes at the bottom of this page: http://us2.php.net/manual/en/domdocument.construct.php

the most relevant of which may be this remark:

Make sure that php_domxml.dll on windows is removed before using the domdocument class as they cannot coexist.
Link to comment
https://forums.phpfreaks.com/topic/132316-solved-php-dom/#findComment-687906
Share on other sites

Freehostia has screwed me over yet again. This is the answer i got from them:

 

Hello. I want this file : extension=php_domxml.dll

removed (commented out)but i dont have access to the php.ini file so i tried to make one of my own and commented out the file. But on my webpage i get the same problem when i am trying to write xml with xslt, so it does not work. More specific, this is the problem:

http://bugs.php.net/bug.php?id=32743&edit=1

Can you remove the file from php.ini so my page will work? thx

 

This was their reply:

 

Hello,

 

Thank you for contacting our Technical Support Department.

 

I have investigated this issue for you and it appears that this would not be possible. I am afraid that you will not be able to use these scripts with your account with us.

 

Best Regards,

..

 

 

Bye bye freehostia

Link to comment
https://forums.phpfreaks.com/topic/132316-solved-php-dom/#findComment-687976
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.