-
Fatal error
Salve ragazzi, ho un problema con il mio spazio altervista.
Ho scritto del codice php provandolo in locale, e funziona.
Quando però l'ho provato sul dominio che ho registrato su altervista non mi funziona più.
L'errore mi viene dato alla riga: $doc->load($url); ed è il seguente:
Fatal error: Call to undefined method: domdocument->load()
Dato che il locale funziona ho pensato fosse un problema di settaggi del server..
Provando a cambiare da php4 a php5 l'errore non c'è più però mi ritrovo come se quel pezzo di codice non venisse eseguito.
Qualcuno saprebbe indicarmi se ci sono modifiche da fare nell' htaccess e come farle?
Grazie in anticipo
-
Dovresti postare più sorgente, altrimenti non possiamo aiutarti.
Ciao!
-
Da una pagina esterna chiamo la funzione: RSS_Display($url);
Ovviamente prima di chiamarla includo questa pagina:
Codice PHP:
<?php
session_start();
$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;
$tnl = $item->getElementsByTagName("pubDate");
$tnl = $tnl->item(0);
$pubDate = $tnl->firstChild->data;
$y["title"] = $title;
$y["link"] = $link;
$y["description"] = $description;
$y["pubDate"] = $pubDate;
$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)
{
global $RSS_Content;
$size = 26;
$i = 0;
$_SESSION[n_date] = "000000";
//$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;
// }
//}
$i++;
$title[$i] = $article["title"];
$link[$i] = $article["link"];
$description[$i] = $article["description"];
$pubDate[$i] = $article["pubDate"];
}
//$page .= "$title[$i] , $link[$i] , $description[$i] , $pubDate[$i] . \n";
//$page .= "<li><a href=\"$link\">$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";
for($i = 3; $i<27; $i++){
$check = substr($pubDate[$i], 5, 11);
$data = date("d M Y");
if ($check == $data){
if(date("d") < 10) { $k = 1; } else { $k = 0; }
$a = substr($pubDate[$i], 17-$k, 2);
$b = substr($pubDate[$i], 20-$k, 2);
$c = substr($pubDate[$i], 23-$k, 2);
$d = $a . $b . $c;
if ($d > $_SESSION[n_date] ){
$_SESSION[n_date] = $d;
$_SESSION[title] = $title[$i];
$_SESSION[link] = $link[$i];
$_SESSION[description] = $description[$i];
}
}
}
}
?>
Le righe commentate fanno parte del codice originale che io ho modificato facendo in modo che non venisse restituita dalla funzione la variabile $page con gli rss da stampare (chiamando quindi la funzione in un echo) ma che vengano invece settate sulle variabili session titolo link e descrizione dell'articolo più recente della giornata.
Ripeto che in locale mi funziona..sul dominio altervista no..
Infatti mettendo un pò di echo in giro per capire dov'è il problema ho notato che la funzione non assegna nulla a $title[$i] ed agli altri array, così come non viene stampato nulla da $article["title"] ecc, mentre in locale va bene.
Per far girare lo script si raccomandava di usare php5 e l'ho messo..col il php4 invece mi da l'errore che ho scritto sopra..
Spero sia stato chiaro e che riusciate ad aiutarmi :roll:
-
nessuno che riesca ad aiutarmi? :(