UGN Security Forums
My ProfileMember DirectoryLogin
Search our ForumsView our FAQView our Site Rules
View our CalendarView our Active TopicsGo to our Main Page

UGN Security Store
 

Network Sites UGN Security, The GoNix Initiative, Elite Web Gamers, Back of the Web, EveryDay Helper, VNC Web Design & Development
August
Su M Tu W Th F Sa
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31
Sponsored Links
Latest Postings
Amazon Gift Card Generator/KeyGen?te
by Gecko666
Yesterday at 05:21 PM
Latest Reviews
Topic Options
Rate This Topic
#19256 - 01/21/03 12:06 PM help a newbie please
xero Offline
Member

Registered: 03/28/02
Posts: 192
ok hi, im working on my site, and im trying to add xml news feeds. it works fine when i only have one, but when i wanna get feeds from multiple sources on one page, it gives me error:

Code:
 Fatal error: Cannot redeclare untag() (previously declared  
and the php code im using to add the xml news feeds is:

Code:
 <?php
$feed = 'http://www.computerworld.com/news/xml/0,5000,73,00.xml';

ini_set('allow_url_fopen', true);
$fp = fopen($feed, 'r');
$xml = '';
while (!feof($fp)) {
	$xml .= fread($fp, 128);
}
fclose($fp);
function untag($string, $tag) {
	$tmpval = array();
	$preg = "|<$tag>(.*?)</$tag>|s";

	preg_match_all($preg, $string, $tags);
	foreach ($tags[1] as $tmpcont){
		$tmpval[] = $tmpcont;
	}
	return $tmpval;
}
$items = untag($xml, 'item');

$html = '

';
foreach ($items as $item) {
	$title = untag($item, 'title');
	$link = untag($item, 'link');

	$html .= '<a href="' . $link[0] . '">' . $title[0] . "</a>
\n";
}
$html .= '';

echo $html;
?> 
i have other feeds as well, so i just simply copy and pasted that same code, pasted again and changed the url of the xml. obviously this isnt the way i should be doing it. can anyone help? im really new at this php stuff :p
_________________________
"Most of our imports come from outside the country" -George W. Bush

http://www.zero-technologies.com

Top
Sponsored Links
      
#19257 - 01/21/03 02:48 PM Re: help a newbie please
SilentRage Offline
DollarDNS Owner

Registered: 03/04/02
Posts: 1273
Loc: OH, USA
The error means that you have 2 functions called 'untag'. I see only 1 untag function in your code however. So are you loading in any code from other files that has an untag function in it? Cause that would hurt ya.
_________________________
Domain Registration, Hosting, Management
http://www.dollardns.net

Top
#19258 - 01/21/03 04:45 PM Re: help a newbie please
jonconley Offline
UGN Super Poster

Registered: 10/08/02
Posts: 955
Loc: Merrill, IA, USA
Did you get my PM?

I think he is running all that code separately for each URL. He could add a loop that will go through each URL or simply remove the calls to function where it occurs later on I believe.

Top
#19259 - 01/21/03 05:35 PM Re: help a newbie please
Deviation187 Offline
Member

Registered: 03/26/02
Posts: 536
Loc: L.A Cal.
lol id give him another couple of hours.. hes still sleeping
_________________________
"Hmm, they have the internet on computers now." - Homer Simpson
http://wired.promodtecnologies.com/

Top
#19260 - 01/21/03 08:55 PM Re: help a newbie please
xero Offline
Member

Registered: 03/28/02
Posts: 192
Yeah, i got the pm, and i agree its not liking the fact that i just copy and pasted the same code lol.. But how would i would i use one piece of code? like say i wanted to get the feed from http://www.blabla.com/1.xml and another one from http://www.blabla.com/2.xml? how would i have to chnage the php to do so? oh and silentrage, yer right, im just copying that same code and pasting it again, changing the url and it is hurting me heh.. how will i use a loop to use only one code for multiple feeds?
_________________________
"Most of our imports come from outside the country" -George W. Bush

http://www.zero-technologies.com

Top

Moderator:  §intå×, Gremelin 
Featured Member
Registered: 08/21/13
Posts: 1
Forum Stats
2147 Members
46 Forums
33889 Topics
69056 Posts

Max Online: 1567 @ 04/25/10 10:20 AM
Top Posters
UGN Security 27051
Gremelin 7192
§intå× 3255
SilentRage 1273
Ice 1146
pergesu 1136
Infinite 1041
jonconley 955
Girlie 908
unreal 860
Newest Members
defghi795767, Devo60, ali, lavos, Zanvin Green
2146 Registered Users
Who's Online
0 registered (), 158 Guests and 236 Spiders online.
Key: Admin, Global Mod, Mod
Latest News


Donate
  Get Firefox!
Get FireFox!