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, Elite Web Gamers, Back of the Web, EveryDay Helper, VNC Web Design & Development
December
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
Our Sponsors


Latest Postings
My friend NEEDS your HELP!
by Gizmo
11/26/08 12:21 AM
Useful PHP Functions & Code
by Gizmo
11/13/08 09:25 PM
UBBCode Tags
by Gizmo
11/13/08 09:25 PM
Topic Options
Rate This Topic
#19256 - 01/21/03 07:06 AM 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
Our Sponsors
Sponsor Our Sponsors

Sponsor Advertisements help keep UGN Security Online.



Support UGN Security by Purchasing our Sponsors Products.
Top  
#19257 - 01/21/03 09:48 AM 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 11:45 AM Re: help a newbie please
jonconley Offline
UGN Super Poster

Registered: 10/08/02
Posts: 954
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 12: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 03: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å×, Gizmo 
Featured Member
Registered: 02/11/08
Posts: 16
Forum Stats
6890 Members
44 Forums
11065 Topics
45844 Posts

Max Online: 677 @ 06/30/07 10:06 PM
Top Posters
Gizmo 6958
UGN Security 4115
§intå× 3252
IceMyst 1449
SilentRage 1273
Ice 1146
pergesu 1134
Infinite 1039
jonconley 954
Girlie 903
Newest Members
lucky vin, prEttyNDistress, AndrewKlilly, border, f4k3m3
6889 Registered Users
Who's Online
1 registered (Gizmo), 13 Guests and 3 Spiders online.
Key: Admin, Global Mod, Mod
Latest News
Update Humpday - Sept 26, 2008
by Gizmo
11/28/08 03:39 AM
Happy Holidays!
by Gizmo
11/27/08 09:09 AM
New Mailing
by Gizmo
11/24/08 01:30 PM
A special update...
by Gizmo
11/24/08 01:10 PM
Required Reading Update...
by Gizmo
11/07/08 11:36 AM


Donate
  Get Firefox!
Get FireFox!