Jump to content

redeclare function !!!


plodos

Recommended Posts

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
Share on other sites

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.