Jump to content

[SOLVED] Warning: domdocument() expects at least 1 parameter, 0 given


FirstBorn

Recommended Posts

Hi,

 

Thanks for reading.

 

I have been using an rss-feed reader script for quite a while now,

but all of a sudden, it started crapping out on Me...

 

I made NO changes to this script and have not even changed anything

to the code that accesses this script, so I have no clue as to why

this is happening.

 

Any ideas as to why this is happening all of a sudden

and how to fix it?

 

I'll include the code below.

 

Thank you VERY MUCH for your help!

 

Thanks,

FirstBorn

 

Here is the Error:

*******************************

Warning: domdocument() expects at least 1 parameter, 0 given in /home/myaccount/public_html/rsslib.php on line 71

Warning: domdocument() expects at least 1 parameter, 0 given in /home/myaccount/public_html/rsslib.php on line 71

 

Fatal error: Call to undefined function: load() in /home/myaccount/public_html/rsslib.php on line 72

 

Fatal error: Call to undefined function: load() in /home/myaccount/public_html/rsslib.php on line 72

 

-----------------------

rsslib.php

-----------------------


<?php
/*
RSS Extractor and Displayer
(c) 2007  Scriptol.com - Licence Mozilla 1.1.
rsslib.php

Requirements:
- PHP 5.
- A RSS feed.

Using the library:
Insert this code into the page that displays the RSS feed:

<?php
require_once("rsslib.php");
echo RSS_Display("http://www.xul.fr/rss.xml", 25);
?>

*/

$RSS_Content = array();

function RSS_Tags($item, $type)
{
	$y = array();
	$tnl = $item->getElementsByTagName("title");
	$tnl = $tnl->item(0);
	$title = $tnl->firstChild->data;

	$tnl = $item->getElementsByTagName("link");
	$tnl = $tnl->item(0);
	$link = $tnl->firstChild->data;

	$tnl = $item->getElementsByTagName("description");
	$tnl = $tnl->item(0);
	$description = $tnl->firstChild->data;

	$y["title"] = $title;
	$y["link"] = $link;
	$y["description"] = $description;
	$y["type"] = $type;

	return $y;
}


function RSS_Channel($channel)
{
global $RSS_Content;

$items = $channel->getElementsByTagName("item");

// Processing channel

$y = RSS_Tags($channel, 0);		// get description of channel, type 0
array_push($RSS_Content, $y);

// Processing articles

foreach($items as $item)
{
	$y = RSS_Tags($item, 1);	// get description of article, type 1
	array_push($RSS_Content, $y);
}
}

function RSS_Retrieve($url)
{
global $RSS_Content;

$doc  = new DOMDocument();
$doc->load($url);

$channels = $doc->getElementsByTagName("channel");

$RSS_Content = array();

foreach($channels as $channel)
{
	 RSS_Channel($channel);
}

}


function RSS_RetrieveLinks($url)
{
global $RSS_Content;

$doc  = new DOMDocument();
$doc->load($url);

$channels = $doc->getElementsByTagName("channel");

$RSS_Content = array();

foreach($channels as $channel)
{
	$items = $channel->getElementsByTagName("item");
	foreach($items as $item)
	{
		$y = RSS_Tags($item, 1);	// get description of article, type 1
		array_push($RSS_Content, $y);
	}

}

}


function RSS_Links($url, $size)
{
global $RSS_Content;

$page = "<ul>";

RSS_RetrieveLinks($url);
if($size > 0)
	$recents = array_slice($RSS_Content, 0, $size);

foreach($recents as $article)
{
	$type = $article["type"];
	if($type == 0) continue;
	$title = $article["title"];
	$link = $article["link"];
	$page .= "<li><a href=\"$link\">$title</a></li>\n";			
}

$page .="</ul>\n";

return $page;

}



function RSS_Display($url, $size)
{
global $RSS_Content;

$opened = false;
$page = "";

RSS_Retrieve($url);
if($size > 0)
	$recents = array_slice($RSS_Content, 0, $size);

foreach($recents as $article)
{
	$type = $article["type"];
	if($type == 0)
	{
		if($opened == true)
		{
			$page .="</ul>\n";
			$opened = false;
		}
		$page .="<b>";
	}
	else
	{
		if($opened == false) 
		{
			$page .= "<ul>\n";
			$opened = true;
		}
	}
	$title = $article["title"];
	$link = $article["link"];
	$description = $article["description"];
	// $page .= "<li><a href=\"$link\">$title</a>";
	$page .= "<li><a href=\"$link\" target=\"_blank\">$title</a>";
	if($description != false)
	{
		$page .= "<br>$description";
	}
	$page .= "</li>\n";			

	if($type==0)
	{
		$page .="</b><br />";
	}

}

if($opened == true)
{	
	$page .="</ul>\n";
}
return $page."\n";

}


?>


 

Link to comment
Share on other sites

Probably your hosting company has enabled another extension, that is conflicting with DOMDocument (that's what comments in manual suggest)

 

Hi Mchl,

 

Thanks for explaining.

 

k, I have My php.ini file from the webhost and the .dll file

is commented out... Of course, 'cause it's on a linux server.

 

So, I've looked through the document that you provided

and can't find anything else that might be conflicting.

But, then again, I'm no php.ini "expert"  :-\

 

Any Ideas?

 

Thanks,

FirstBorn

 

Link to comment
Share on other sites

use phpinfo() if indeed both these extensions are loaded. Then consult your hosting company on how to disable one if needed.

 

Hi Mchl,

 

Thanks for your help.

 

I actually did a phpinfo(); and noticed that 4.xx was running

for some reason... I went into the CPanel into the php configuration,

and changed it BACK to 5 and that fixed the issue...

 

I have no clue as to why it swapped backwards to 4 and the

webhost said that nobody has touched the server in 14 days...

 

Weird, VERY Weird, but it's currently fixed...

 

Again, thank you VERY much for your help!

 

Thanks,

FirstBorn

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.