problem with the code

Discussion and education for beginner / novice programmers interested in embarking on the development process to take advantage of the extensible nature of the Joomla! CMS.
Locked
mukherjisandeep
Joomla! Fledgling
Joomla! Fledgling
Posts: 3
Joined: Thu Jul 17, 2008 11:57 am

problem with the code

Post by mukherjisandeep » Fri Jul 18, 2008 12:50 pm

Hi all,
The following code when run gives an error "Fatal error: Cannot redeclare joins() (previously declared in C:\xampp\htdocs\accnet\PHPoperations\PHPselectLink.php:9) in C:\xampp\htdocs\accnet\PHPoperations\PHPselectLink.php on line 30"

Code: Select all

<? include "PHPmysqlconnection.php";
/*********************************************************************************************************************************************************************
*@auther:	Sandeep Mukherji
*@version:	1.0
*@Objective:	Function for populating the link drop down box
*@Function name:	select_link	
*@Create date:	July 16, 2008
*********************************************************************************************************************************************************************/
function joins($link,$arg)
{
	$id = mysql_fetch_row(mysql_query("select id, heading from tab_link where name ='".$link."'")); 
/* 
*	id of the corresponding link is selected, this id will be used to select all the subheadings.
*	Note that: we have preassumed that one link (or page) can hold only one main Heading, and a main Heading can have
*	many subheadings. So the id of a link is same as the id of a main Heading.
*	Now after the select query $id[0][0] have the id of the link and $id[0][1] have the main Heading.
*/
	$count_max = mysql_fetch_row(mysql_query("select max(id) from tab_x where link_id='".$id[0][0]."'"));
	$count_min = mysql_fetch_row(mysql_query("select min(id) from tab_x where link_id='".$id[0][0]."'"));
	if($arg == "max")
		return $count_max;
	else if($arg == "min")
		return $count_min;
	else if($arg == "heading")
		return $id[0][1];
	else if($arg == "tab_link_id")
		return $id[0][0];
	else
		return 0;
}

function select_link($selected)
{
	$count = mysql_fetch_row(mysql_query("select max(id) from tab_link"));
	$c = 1;
	while($c <= $count[0])	
	{
		$selection[$c] = mysql_fetch_row(mysql_query("select name from tab_link where id ='".$c."'"));	
		if($selection[$c][0])
		{	
			if($selection[$c][0] == $selected)
			{
				echo "<option selected>".$selection[$c][0]."</option>";
			}
			else
				echo "<option>".$selection[$c][0]."</option>";							
		}									
		$c++;
	}
}
	
function select_subheading($link)
{
	$max = joins($link,"max");
	$min = joins($link,"min");
	$c = $min[0];
	$index = 0;
	while($c <= $max[0])	
	{
		$selection[$index] = mysql_fetch_row(mysql_query("select subHead from tab_link where id ='".$c."'"));	
		if($selection[$index][0])
		{	
			echo "<option>".$selection[$index][0]."</option>";		
			$index++;			
		}	
		$c++;
	}
}
	/*********************************************************************************************************************************************************************
*@auther:	Sandeep Mukherji
*@version:	1.0
*@Objective:	Function for the selecting all the values and stored in the a variable named $value
*@Function name:	Select
*@Create date:	July 16, 2008
*********************************************************************************************************************************************************************/
function selectone($name,$index)
{
	$value = mysql_fetch_row(mysql_query("select * from tab_link where name='".$name."'"));
	echo $value[$index];
	return $value[$index];
}
?>
can anyone suggest how to get rid of the error?

Locked

Return to “Joomla! Coding 101”