Hi all,
Can anyone see the problem with the following script?
I get the following error message:
Fatal error: Cannot redeclare getparentid() in /usr/local/etc/httpd/sites/kosbab.org/themotoringdirectory.com/htdocs/admin/duplicate_urls.php on line 40
<?
session_start();
//check session variable
if (session_is_registered("valid_user_onestopm"))
{
?>
<?
include_once("include/header.inc.php");
include_once("include/dbconnect_admin.php");
if($delete){
foreach ($checkbox as $key=>$value){
$delete = mysql_query("delete from $table where CatID=$value",$db);
}
?>
<META HTTP-EQUIV="refresh" CONTENT="1; URL=duplicate_urls.php">
<?
} else if($url){
$result1 = mysql_query ("SELECT * FROM $table WHERE url = '$url'");
while ($row1 = mysql_fetch_array($result1)) {
$new_id = $row1["CatID"];
$new_new_url = $row1["url"];
echo "<form method=\"post\" action=\"duplicate_urls.php\">";
echo "$new_id | <a href='edit.php?id=$new_id'>edit</a> | <a href='delete.php?id=$new_id' onClick=\"return confirm('Are you sure?')\">delete</a> | <input type=\"checkbox\" name=\"checkbox[]\" value=\"$new_id\"> |";
function getParentID($childID){
$row = mysql_fetch_row(mysql_query("SELECT CatParent FROM cat1 WHERE CatID = $childID ORDER BY CatID"));
return $row[0];
}
if($id > 1){
$nextID = $id;
do{
$nextID = $ar[$count++] = getParentID($nextID);
} while($nextID > 1);
$ar = array_reverse($ar);
foreach($ar as $parent){
if($parent > 1){
$row = mysql_fetch_row(mysql_query("SELECT CatName FROM cat1 WHERE CatID = $parent"));
echo " <b>></b> <a class=\"au\" href=\"../motoring.php?id=$parent\">$row[0]</a>";
}
else {
echo "<table width=\"100%\" border=\"0\" bgcolor=\"#ffffff\"><tr><td bgcolor=\"#ffffff\" width=\"100%\"><a class=\"au\" href=\"../index.htm\">Home</a>";
}
}
$row = mysql_fetch_row(mysql_query("SELECT CatName FROM cat1 WHERE CatID = $id"));
echo " <b>></b> <b>$row[0]</b></td></tr></table>";
//echo "<a class="au" href=\"melbourne_home.php?id=$id\">$row[0]</a>";
}
echo "<br>";
}
echo "<br><input type=\"submit\" value=\"Delete Selected Listing(s)\" name=\"delete\">";
echo "</form>";
} else {
$result = mysql_query ("SELECT * FROM $table WHERE url != '' GROUP BY url HAVING COUNT(url) > 1");
$resultsnumber = mysql_numrows($result);
echo "<table cellpadding=2 cellspacing=1 border=0>";
echo "There are <B>$resultsnumber</B> duplicate URL's<BR><BR>";
$alternate = "2";
while ($row = mysql_fetch_array($result)) {
$id = $row["CatID"];
$new_url = $row["url"];
if ($alternate == "1") {
$color = "#ffffff";
$alternate = "2";
}
else {
$color = "#efefef";
$alternate = "1";
}
//if ($new_url > 1){
echo "<tr bgcolor=$color><td>$new_url</td><td><a href='duplicate_urls.php?url=$new_url'>see details</a></td></tr>";
//}
}
echo "</table><br><br>";
?>
<?
}
}
else
{
// You are not logged in.
//Only logged in members may see this page.
require_once("warning.htm");
}
?>
Cheers,
micmac