I am a new in PHP coding and I wanted to make a code getting information from a RSS of a site to create a site for a game called TM. TM sites are different they are called Manialink. There is no probleme I writed the code who works on my computer ho has php5 but my host use php4. There my code stop working
here is the version working on php5
Code: Select all
<?php echo'<?xml version="1.0" encoding="utf-8" ?>'; ?>
<manialink>
<type>default</type>
<line height='0.45'>
<cell width='1.4'>
<icon height='0.44' url='http://www.trackmania.gen.tr' width='1.4'>http://www.trackmania.gen.tr/index/wp-content/themes/neon-green-10/images/header.jpg</icon>
</cell>
</line>
<?php
$doc = new DOMDocument();
$doc->load( 'http://trackmania.gen.tr/index.php?type=rss;action=.xml' );
$items = $doc->getElementsByTagName("item");
foreach( $items as $item )
{
$names = $item->getElementsByTagName("title");
$name = $names->item(0)->nodeValue;
$links = $item->getElementsByTagName("link");
$link = $links->item(0)->nodeValue;
$authors = $item->getElementsByTagName("author");
$author = $authors->item(0)->nodeValue;
$categorys = $item->getElementsByTagName("category");
$category = $categorys->item(0)->nodeValue;
$pubDates = $item->getElementsByTagName("pubDate");
$pubDate = $pubDates->item(0)->nodeValue;
echo "
<line height='0.05'>
<cell width='0.4' bgcolor='000E' ><text textcolor='FFFF'>$pubDate</text></cell>
<cell width='1' bgcolor='000E' ><text textcolor='FFFF'>$category</text></cell></line>
<line height='0.08'><cell width='1.4' bgcolor='FFFE' ><text textcolor='000F' textsize='2.5'>
\$l[$link]$name\$l($author)</text></cell></line>";
}
?>
</manialink>Parse error: syntax error, unexpected T_OBJECT_OPERATOR in /mnt/163/sda/c/e/oliverde8/TM/gen.tr/mania-rss.php on line 17
_____________________________________________________________
This is the version ho should have work on php4
Code: Select all
<?php echo'<?xml version="1.0" encoding="utf-8" ?>'; ?>
<manialink>
<type>default</type>
<line height='0.45'>
<cell width='1.4'>
<icon height='0.44' url='http://www.trackmania.gen.tr' width='1.4'>http://www.trackmania.gen.tr/index/wp-content/themes/neon-green-10/images/header.jpg</icon>
</cell>
</line>
<?php
function get_value ( $node )
{
$result = '' ;
$sub_nodes = $node->child_nodes ( ) ;
foreach ( $sub_nodes as $sub_node )
{
if ( $sub_node -node_type ( ) == XML_TEXT_NODE )
{
$result .= $sub_node -node_value ( ) ;
}
}
return ( $result ) ;
}
$doc = domxml_open_file ('http://trackmania.gen.tr/index.php?type=rss;action=.xml' );
$items = $doc->get_elements_by_tagname("item");
foreach( $items as $item )
{
$names= $item->get_elements_by_tagname("title");
$name = get_value ($names) ;
$links = $item->get_elements_by_tagname("link");
$link = get_value ($links) ;
$authors = $item->get_elements_by_tagname("author");
$author = get_value ($authors) ;
$categorys = $item->get_elements_by_tagname("category");
$category = get_value ($categorys) ;
$pubDates = $item->get_elements_by_tagname("pubDate");
$pubDate = get_value ($pubDates) ;
echo "
<line height='0.05'>
<cell width='0.4' bgcolor='000E' ><text textcolor='FFFF'>$pubDate</text></cell>
<cell width='1' bgcolor='000E' ><text textcolor='FFFF'>$category</text></cell></line>
<line height='0.08'><cell width='1.4' bgcolor='FFFE' ><text textcolor='000F' textsize='2.5'>
\$l[$link]$name\$l($author)</text></cell></line>";
}
?>
</manialink>Fatal error: Call to a member function on a non-object in /mnt/163/sda/c/e/oliverde8/TM/gen.tr/3.php on line 13
______________________________________________________
What should I do to to make it work. I already searched on the php.net site but can not fond more than what I did.
I olso searched the Forum but find nothing
Thanks for the help