plodos Posted March 5, 2008 Share Posted March 5, 2008 rss.php <? include "dbconfig.php"; header("Content-type: text/xml\n\n"); echo "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?> <rss version=\"2.0\"> <channel> <title>World</title> <description>Open</description> <copyright>Copyright 2008, http://www.worlds.org</copyright> <link>http://www.worlds.org/notice/rss.php</link> <language>ENG</language> "; ?> <? $a=mysql_query("select * from notice_table ORDER BY user_id DESC LIMIT 10") or die(mysql_error()); while ( $data = mysql_fetch_array($a) ) { $id = $data['user_id']; $title=$data['title']; $date=$data['date']; $notice=$data['notice']; ?> <?php function conv_function($convert) { $convert = str_replace('"',""",$convert); $convert = str_replace(">",">",$convert); $convert = str_replace("<","<",$convert); return $convert; } ?> <item> <title><? echo $title; ?></title> <pubDate><? echo $date; ?></pubDate> <description><? echo conv_function($notice); ?></description> <link>http://www.worlds.org/notices.php?exploit=<? echo $id; ?></link> </item> <? } echo " </channel> </rss>"; ?> code is working but for only lastest data... RSS reader gives that error: Fatal error</b>: Cannot redeclare conv_function() (previously declared in /home/.wings/worlds.org/notice/rss.php:26) in <b>/home/.wings/world/notice/rss.php</b> on line 26 how can I redeclare conv_function() this function? Link to comment https://forums.phpfreaks.com/topic/94524-redeclare-function/ Share on other sites More sharing options...
Agricola Posted March 5, 2008 Share Posted March 5, 2008 Move your function before the while loop, preferbly at top of page. you can only declare function once, and as you keep on declaring it with every pass of the loop it throws an error. this is the function <?php function conv_function($convert) { $convert = str_replace('"',""",$convert); $convert = str_replace(">",">",$convert); $convert = str_replace("<","<",$convert); return $convert; } ?> Link to comment https://forums.phpfreaks.com/topic/94524-redeclare-function/#findComment-484005 Share on other sites More sharing options...
rhodesa Posted March 5, 2008 Share Posted March 5, 2008 you can't redeclare it...it's already been declared in /home/.wings/worlds.org/notice/rss.php...your options are: -If they are different functions, just use a different name -If they are the same function, I would recommend moving the function to a separate file (like functions.inc) and then use a require_once('functions.inc') to include the file. The quickest solution though if they are the same function is to just test if they function exists already: <?php if(!function_exists('conf_function')){ function conv_function($convert) { $convert = str_replace('"',""",$convert); $convert = str_replace(">",">",$convert); $convert = str_replace("<","<",$convert); return $convert; } } ?> Link to comment https://forums.phpfreaks.com/topic/94524-redeclare-function/#findComment-484007 Share on other sites More sharing options...
plodos Posted March 5, 2008 Author Share Posted March 5, 2008 if(!function_exists('conv_function')){ ................................ } very usefull function..thnx for help me! Link to comment https://forums.phpfreaks.com/topic/94524-redeclare-function/#findComment-484055 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.