Not your normal undefined index

So, according to the server we have an undefined index “category” on line 405…
However, we don’t use $category anywhere in the script, nor is there any similar vars 10 lines above on or 10 lines below.

Because this file is so large, I am only posting the method that 405 falls in

Suggestions?[php][embed=425,349]public function PrintUserProductTable($connx,$GET_arr,$uid){

	$this->PrintUserToolBar($GET_arr);

	//Determine the category
	if (isset($GET_arr['category'])){
		$cate = "'" . $GET_arr['category']. "'";
	}

	if (!isset($GET_arr['category'])
		||empty($GET_arr['category']) 
		|| $GET_arr['category'] == 'all') {
		$cate = '"'*'"';
	}
	
	if (isset($GET_arr['search'])){$search = $GET_arr['search'];}
	if (!isset($GET_arr['search'])){$search = "";}
	
	//Determine the sort mode
	$sortby = "ASC";
	if (isset($GET_arr['sortby']) && $GET_arr['sortby']=='-price'){$sortby="DESC";}

	//Set the rental or buy mode
	$mode = "price_rental";
	if (isset($GET_arr['mode']) && $GET_arr['mode']=='buy'){$mode = 'price_buy';}

	//Set default for perpage
	if(!isset($GET_arr['perpage'])||empty($GET_arr['perpage'])){$GET_arr['perpage']="10";}

	//Set defualt page
	if(!isset($GET_arr['page'])||empty($GET_arr['page'])){$GET_arr['page']="1";}
	
	//IF SEARCHING
	if (isset($GET_arr['search'])){
		$cntsql = "SELECT * FROM products 
		WHERE IsActive='1' 
		AND name LIKE ('%$search%')
		OR desc_long LIKE ('%$search%')
		OR desc_short LIKE ('%$search%')
		";
	}
	//IF NOT SEACHING
	if (!isset($GET_arr['search'])){
		$cntsql = "SELECT * FROM products WHERE IsActive='1' AND category=$cate";
	}
	
	$r = mysqli_query($connx,$cntsql) or die(mysqli_error($connx));
	if(!is_bool($r)){
		$rows = mysqli_num_rows($r);
	}
	

	//Determine haw many pages are availble

	$pages = (ceil($rows/$GET_arr['perpage']));
	$rangemin = ($GET_arr['page'] - 1) * $GET_arr['perpage'];
	$rangemax = $GET_arr['perpage'];

	//Build PAGE the url
	$url = "index.php?pg=products&perpage=" .$GET_arr['perpage']. "&mode=" .$mode. "&category=" .$cate. "&sortby=" .$sortby . "&search=". $search;

	//Build the page navigation toolbar
	//For pages below the current page
	echo '<div class=itempagenav>';

	for ($i = $GET_arr['page'] - $this->showpagerange; $i<$GET_arr['page']; $i++ )
	{
		$pg = $i;
		if ($pg <= 0)
		{
			continue;
		}

		echo '<a href="'. $url .'&page='. $pg  .'">pg '. $pg  .' </a>&nbsp'	;
	}

	//For the current page
	echo '<b><a href="'. $url .'&page='. $GET_arr['page']  .'">pg '. $GET_arr['page'] .' </a></b>&nbsp'	;

	//For pages above the current page
	for($i=1; $i<=$this->showpagerange; $i++)
	{
		$pg = $GET_arr['page'] + $i;
		if ($pg > $pages) 
		{
			break;
		}
		echo '<a href="'. $url .'&page='. $pg  .'">pg '. $pg  .' </a>&nbsp'	;
	}
	echo '<form name="productsearch_user" style="float:right;" action="./index.php?pg=products&action=viewproducttable" method="GET" enctype="multipart/form-data"><input hidden name="pg" value="products"><input type="text" name="search" value="' .$search. '"><input type="submit" value="Search"></form>';
	echo '</div>';
	//End build nav bar
	
	if(isset($GET_arr['search']))
	{
	$sql = "SELECT * FROM products 
		WHERE IsActive='1' 
		AND name LIKE ('%$search%')
		OR desc_long LIKE ('%$search%')
		OR desc_short LIKE ('%$search%')
		ORDER BY name, $mode $sortby
		LIMIT $rangemin, $rangemax ";
		
	}
	if(!isset($GET_arr['search'])){
		$sql = "SELECT * FROM products 
			WHERE IsActive='1' 
			AND category=$cate 
			ORDER BY name, $mode $sortby
			LIMIT $rangemin, $rangemax ";
	}
	
	$result = mysqli_query($connx,$sql) or die(mysqli_error($connx));

	//Div METHOD (able to be styled)
    if(mysqli_num_rows($result) < 1){echo '<p>No Results Found.</p>';}
	
	if($this->displaymode == "div"){
		
			
		while($row = mysqli_fetch_assoc($result)){
			if(!isset($row['img_file_1'])){$row['img_file_1']='default.jpeg';}
			
			
			
			echo '<div class="itemcontainer">';		
			echo '<div class="itemtitle"><a href="index.php?pg=products&action=viewproduct&uid='.$row["uid"].'">'.$row["name"].'</a>  ['.$row['category'].']';
					if ($this->IsBuy($connx,$row["uid"])){echo'<span style="float:right;margin-left:20px;"><b>$'.$row["price_buy"].' </b> - <a href="'.$this->carturl.'&product_id='.$row['uid'].'&user_id='.$uid. '&action=buyitem&perpage=' . $GET_arr["perpage"]. '&mode=' .$mode. '&category=' .$GET_arr["category"]. '&sortby=' .$sortby. '">Buy it!</a></span>';}
					if ($this->IsRental($connx,$row["uid"])){echo'<span style="float:right;margin-left:20px;"><b>$'.$row["price_rental"].' </b> - <a href="'.$this->carturl.'&product_id='.$row['uid'].'&user_id='.$uid.'&action=rentitem&perpage=' . $GET_arr["perpage"]. '&mode=' .$mode. '&category=' .$GET_arr["category"]. '&sortby=' .$sortby. '">Rent it!</a></span>';}
			echo '</div>
			
					<div class="itemimg"><a href="index.php?pg=products&action=viewproduct&uid='.$row["uid"].'">
						<img src="'. $this->uploaddir. "/" .$row['img_file_1']. '" alt="No Image for this Product"">
					</a></div>
					
					<div class="itemdetail">
							<p>'.$row['desc_short'].'</p>
					</div>
					
			
			';

			echo '</div>';
		}
	}

	if($this->displaymode == "table"){

	//Table METHOD	

	//Start TABLE
	echo '<table class="producttable">';
		echo '<tr><th>Name</th><th>Image</th><th>Short Description</th><th>Long Description</th><th>Category</th><th>Price</th></tr>';
		while($row = mysqli_fetch_assoc($result)){
			echo '<tr>';
			echo '<td><a href="index.php?pg=products&action=viewproduct&uid='.$row["uid"].'">'.$row["name"].'</a></td>';
			echo '<td><img style="width:60px;" src="'. $this->uploaddir. "/" .$row['img_file_1']. '" alt="No Image for this Product""></td>';
			echo '<td>'.$row["desc_short"].'</td>';
			echo '<td>'.$row["desc_long"].'</td>';
			echo '<td>'.$row["category"].'</td>';
			echo '<td>$'.$row[$mode].'</td>';
		}
		echo '</table>';
	}
}[/embed][/php]

its not $GET_, its $_GET, and $_GET[‘category’] is the index.

Sponsor our Newsletter | Privacy Policy | Terms of Service