Pagination problem with mod_rewrite

yaah it’s there
i din’t copy tht part of the code

That was the first thing I noticed. Rajju14, you’re asking for help with your session but you’re not posting the session code?

Where do you handle the session? That’s what we need to see.

[SIZE=“6”]ok i am posting the total code

This the display page…
[/SIZE]

<?php
session_start();
//error_reporting(E_ALL);
include(“includes/dbconfig.php”);
include(“includes/commonvariables.php”);
include(“includes/searchvar.php”);
include_once(“includes/common.php”);
include(“includes/RssAgent.php”);
require_once “includes/Paginated.php”;
require_once “includes/TrailingLayout.php”;
//print_r($_SERVER);//[‘QUERY_STRING’] ;
?>
<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN”
http://www.w3.org/TR/html4/loose.dtd”>
<html>
<head>
<?
if( $_GET[‘cat_id’] <> ‘’){
$query=“SELECT * FROM rim_categories where cat_id = '” . $_GET[‘cat_id’] . “'”;
//echo $query;
$pcat = getSqlRow($query);
$cat_name = $pcat[‘cat_name’];?>
<title><?echo $cat_name?> Deals - <?echo $pcat[‘SEODealsKeywords’]?> | Zirafi.com</title>
<meta name=“description” content = “<?echo $pcat[‘meta_desc’]?>”>
<meta name=“keywords” content = “<?echo $pcat[‘meta_keywords’]?>”>
<?
}
else if( $_GET[‘adv_id’] <> ‘’){?>
<title><?echo $_GET[‘adv_id’]?> Daily Deals - Free Shopping Deals Online</title>
<meta name=“description” content = “<?echo $_GET[‘adv_id’]?> Daily Deals - Free Shopping Deals Online”>
<meta name=“keywords” content = “<?echo $_GET[‘adv_id’]?> Daily Deals - Free Shopping Deals Online”>

<?
$cat_name=“”;
}
else{
?>
<title>Daily Deals - Free Shopping Deals Online | Ziraffi.com</title>
<meta name=“description” content = “Daily Deals - Free Shopping Deals Online”>
<meta name=“keywords” content = “Daily Deals - Free Shopping Deals Online”>
<?}?>

<meta http-equiv=“Content-Type” content=“text/html; charset=iso-8859-1”>
<meta name=“robots” content=“index, follow” />
<!–Google Analytics Code–>
<script type=“text/javascript”>

var _gaq = _gaq || ;
_gaq.push([‘_setAccount’, ‘UA-24361236-1’]);
_gaq.push([‘_trackPageview’]);

(function() {
var ga = document.createElement(‘script’); ga.type = ‘text/javascript’; ga.async = true;
ga.src = (‘https:’ == document.location.protocol ? ‘https://ssl’ : ‘http://www’) + ‘.google-analytics.com/ga.js’;
var s = document.getElementsByTagName(‘script’)[0]; s.parentNode.insertBefore(ga, s);
})();

</script>
<link rel=“stylesheet” href=“/images/Stylemain.css” type=“text/css” media=“all” />
<link rel=“stylesheet” href=“/images/Style.css” type=“text/css” media=“all” />

</head>
<body>
<style type=“text/css”>
.style1 {
font-family:Verdana;
font-size:18px;
color: #FF3000;
font-weight:bold;
font-style:normal;
}
.style12 {
color: #40A12F;
font-size: 16px;

}
</style>

<div id=“content”>

<?php
// For pagination
$filePath = “Deals.php”;
$page = $_GET[‘page’];
$home=“false”;
if ($_GET[‘cat_id’] <> ‘’)
{
$cat_id = $_GET[‘cat_id’];
$catqry = “select Keywords from rim_categories where cat_id = '” . $cat_id . “'”;
//echo $catqry;
$catarr = getSqlRow($catqry);
$keyword = $catarr[‘Keywords’];
if ($keyword <> ‘’)
{
$keywords=split(“,”,$keyword);//Breaking the string to array of words

//echo $catsort;
}
//$limit =50;
//$pagelimit = 50;
$home=“false”;
}
else
{
$cat_id=“”;
}
echo “cat” . $cat_id;
if ($_GET[‘adv_id’] <> ‘’)
{
$adv_id = $_GET[‘adv_id’];
//$limit =70;
//$pagelimit = 70;
$home=“false”;
}
else
{
$adv_id=“”;
}
if ($limit == 0)
{
//$limit =50;
//$pagelimit = 50;
}

if(isset($_GET[‘start’]) ){
$start = $_GET[‘start’];
}else{
$start = 0;
}
$filePath = “Deals.php”;
//print_r($_SESSION);
if ($cat_id <> ‘’)
{
//$additionalvar .= “&cat_id=” . $cat_id;
$additionalvar .= basename($_SERVER[‘REQUEST_URI’]);
}
if ($adv_id <> ‘’)
{
//$additionalvar .= “&adv_id=” . $adv_id;
}
////Pagination End

$_SESSION[‘menuoption’] = “DEALS”;
include “includes/header.php”;
include “Header.php”;
$limit = 80;
$listingImageWidth = LISTING_IMAGE_WIDTH; //AMAZON_LISTING_IMAGE_WIDTH;//
//$cat_id=$tempcat;
if(!isset($page)){$page=0;}
echo “page” . $page;
//print_r($_SESSION);
if($page<1)
{
//echo “empty”;

include “extract.php”;
shuffle($_SESSION[‘gDealArray’]);
}
else
{
//$gPromotionArray = $_SESSION[‘gDealArray’];
}

//echo $nbDeals;
?>
<div id=“main”>
<?php

$icnt=0;
$total = count($_SESSION[‘gDealArray’]);
//echo $total;
if ($total<=0)
{
include “nosearch.php”;
}
$icnt=0;
$gDealArray = $_SESSION[‘gDealArray’];
$pagedResults = new Paginated($gDealArray, 80, $page);
//shuffle($pagedResults);
while($getdeals = $pagedResults->fetchPagedRow())
{
if( strlen($getdeals[‘specialnote’]) < 68 ){
$getdeals[‘specialnote’] = $getdeals[‘specialnote’];
}else{
$getdeals[‘specialnote’] = substr($getdeals[‘specialnote’], 0, 68) . “…”;
}
if( strlen($getdeals[‘shipping_desc’]) < 80 ){
$getdeals[‘shipping_desc’] = $getdeals[‘shipping_desc’];
}else{
$getdeals[‘shipping_desc’] = substr($getdeals[‘shipping_desc’], 0, 80) . “…”;
}
if( strlen($getdeals[‘prows_title’]) < 100 ){
$getdeals[‘prows_title’] = $getdeals[‘prows_title’];
}else{
$getdeals[‘prows_title’] = substr($getdeals[‘prows_title’], 0, 100) . “…”;
}
$icnt = $icnt+1;
if ($getdeals[‘type’] == “Deal”)
{?>
<div id=“innermain”>
<?}
//echo “deal”;
if($getdeals[‘advertiser’] == “eBay”)
{
$getdeals[‘prows_image’] = fix_amazon_image_size($getdeals[‘prows_image’], EBAY_IMAGE_SIZE);
}
else{
$getdeals[‘prows_image’] = fix_amazon_image_size($getdeals[‘prows_image’], AMAZON_IMAGE_SIZE);
}
?>

			&lt;div id="dealimg"&gt;
				&lt;?if ($getdeals['source'] == 'cj'){
				if ($getdeals['table'] == 'tbl_deals_ws'){			
				?&gt;
				&lt;a class="_link" href="/ProductDetails.php?prod_id=&lt;?=$getdeals['prod_id']?&gt;&type=1" target="_blank" &gt; &lt;img border = "0" height = "&lt;?=$listingImageWidth?&gt;"  width= "&lt;?=$listingImageWidth?&gt;" src = "&lt;?=$getdeals['prows_image']?&gt;"&gt; &lt;/a&gt;
				&lt;?}else{?&gt;
				&lt;a class="_link" href="/ProductDetails.php?prod_id=&lt;?=$getdeals['prod_id']?&gt;&type=1" target="_blank"&gt; &lt;img border = "0" height = "&lt;?=$listingImageWidth?&gt;"  width= "&lt;?=$listingImageWidth?&gt;" src = "&lt;?=$getdeals['prows_image']?&gt;"&gt; &lt;/a&gt;
				&lt;?}}else{?&gt;
				&lt;a class="_link" href="&lt;?=$getdeals['prows_url']?&gt;&type=1" target="_blank"&gt; &lt;img border = "0" height = "&lt;?=$listingImageWidth?&gt;"  width= "&lt;?=$listingImageWidth?&gt;" src = "&lt;?=$getdeals['prows_image']?&gt;"&gt; &lt;/a&gt;
				&lt;?}?&gt;
			&lt;/div&gt;
			&lt;div id ="dealsdesc"&gt;
			&lt;div id="desc"&gt;
				&lt;span class="smallgreytext"&gt;&lt;?=$getdeals['Advertiser']?&gt;&lt;/span&gt;&lt;br&gt;
				&lt;?//echo "Title".$getdeals['prows_title'];?&gt;
				&lt;?
				if( strlen($getdeals['prows_title']) &lt; 100 ){
			  	$getdeals['prows_title'] =  $getdeals['prows_title'];
				  }else{
			  	$getdeals['prows_title'] = substr($getdeals['prows_title'], 0, 100) . "...";  
				  }	
				//echo $getdeals['imp_url'];	
				if ($getdeals['source'] == 'cj'){
				if ($getdeals['table'] == 'tbl_deals_ws'){			
				?&gt;
				&lt;a class="_link" href="/ProductDetails.php?prod_id=&lt;?=$getdeals['prod_id']?&gt;&type=1" target="_blank" &gt;&lt;span class="_boldlink"&gt;&lt;?=$getdeals['prows_title']?&gt;&lt;/span&gt;&lt;img src="&lt;?=$getdeals['imp_url']?&gt;"&gt; &lt;/a&gt;&lt;br&gt;
				&lt;?}else{?&gt;
				&lt;a class="_link" href="/ProductDetails.php?prod_id=&lt;?=$getdeals['prod_id']?&gt;&type=2" target="_blank"&gt;&lt;span class="_boldlink"&gt;&lt;?=$getdeals['prows_title']?&gt;&lt;/span&gt;&lt;img src="&lt;?=$getdeals['imp_url']?&gt;"&gt; &lt;/a&gt;&lt;br&gt;
				&lt;?}}else{?&gt;
				&lt;a class="_link" href="&lt;?=$getdeals['prows_url']?&gt;" target="_blank"&gt;&lt;span class="_boldlink"&gt;&lt;?=$getdeals['prows_title']?&gt;&lt;/span&gt;&lt;/a&gt;&lt;br&gt;
				&lt;?}?&gt;
				&lt;span class="dealpagetext"&gt;List Price : &lt;strike&gt;&lt;?=$getdeals['prows_price']//truncate($item['prows_description'], DESCR_LENGTH)?&gt;&lt;/strike&gt;&lt;/span&gt;&lt;br&gt;
				&lt;?php
					$reg_price = (float) str_replace('$', '', $getdeals['prows_price']);
					//echo $reg_price;
					$sale_price = (float) str_replace('$', '', $getdeals['sale_price']);
					if ($getdeals['Advertiser'] == "Ebay")
					{?&gt;
						&lt;span class="dealpagetext"&gt;You Save : &lt;/span&gt;&lt;span class="savestyle"&gt;&lt;?=$getdeals['rebate']?&gt;&lt;/span&gt;&lt;br&gt;
					&lt;?}
					else
					{
						$rebate = number_format($reg_price - $sale_price, 2);
						//ECHO "rebate" . ;
						$getdeals['rebate'] = (int) (($rebate * 100.0) / $reg_price);?&gt;
						&lt;span class="dealpagetext"&gt;Sale Price : &lt;/span&gt;&lt;span class="dealgreentext"&gt;&lt;?=$getdeals['sale_price']//truncate($item['prows_description'], DESCR_LENGTH)?&gt;&lt;/span&gt;&lt;br&gt;
						&lt;span class="dealpagetext"&gt;You Save : &lt;/span&gt;&lt;span class="savestyle"&gt;&lt;?=$getdeals['rebate']?&gt;%&lt;/span&gt;&lt;br&gt;
					&lt;?}
				?&gt;
				
				&lt;?if ($getdeals['specialnote']&lt;&gt; '')
				{?&gt;
				&lt;span class="mediumgreentext"&gt;&lt;?=$getdeals['specialnote']?&gt;&lt;/span&gt;&lt;br&gt;
				&lt;?php
				}
				if ($getdeals['shipping_desc']&lt;&gt; '')
				{
				?&gt;
				&lt;span class="mediumgreentext"&gt;&lt;?= $getdeals['shipping_desc']?&gt;&lt;/span&gt;&lt;br&gt;
				&lt;?}?&gt;
			&lt;/div&gt;
			&lt;/div&gt;
		
&lt;!--		&lt;div id="innermain"&gt;
			&lt;img src="tmp/zcimage03.jpg" width="230px"&gt;
		&lt;/div&gt;
	&lt;div id = "blank"&gt;
	&lt;/div&gt;
	&lt;div id = "blank"&gt;
	&lt;/div&gt;
	&lt;div id = "blank"&gt;
	&lt;/div&gt;--&gt;

</div>
<?
}
?>
</div>

	&lt;div id="secondary"&gt;

<?
$_SESSION[‘page’] = ‘All’;
$_SESSION[‘SEOPage’] = “Deals”;
//$_SESSION[‘DealsArr’] = $_SESSION[‘gDealArray’];
?>

		&lt;?include "classifieds.php";?&gt;
		&lt;?include "categories.php";?&gt;

<?include “BannerAds.php”;?>
<?include “Advertisers.php”;?>
<?include “LongBanner.php”;?>

	&lt;/div&gt;
	&lt;div id="footer"&gt;&lt;span class="bottomlinks"&gt;&lt;center&gt;&lt;?$pagedResults-&gt;setLayout(new TrailingLayout());
echo $pagedResults-&gt;fetchPagedNavigation($additionalvar);?&gt;&lt;/center&gt;&lt;/span&gt;&lt;/div&gt;

	&lt;div id="footer"&gt;
		&lt;center&gt;&lt;?include "footer.php";?&gt;&lt;/center&gt;
	&lt;/div&gt;

</div>
</body>
</html>

This is the file where I am post the session data. u can see the last four lines where i am setting the session data

<?
session_start()
$traceenable = true;
if($traceenable==true){
$myFile = “/home/zadmin/logs/Querylog.log”;
$fh = fopen($myFile, ‘w’) or die(“file invalid”);}
$idx=0;
//echo $cat_id ;
//$Dealsquery=“SELECT * FROM rim_products where (expire_date>CURDATE() or expire_date=‘0000-00-00’) and product_status=1 and kind=0 “;
$Dealsquery=“SELECT * FROM rim_products where (expire_date>CURDATE() or expire_date=‘0000-00-00’) and product_status=1 and kind=0 and specialnote <> ‘’”;// and (specialnote like ‘%rebate%’ or specialnote like ‘%save%’ or specialnote like ‘%Free Shipping%’ or specialnote like ‘%savings%’ ) “;
if($cat_id <> ‘’)
{
// $Dealsquery= $Dealsquery . " and cat_id = " . $cat_id;
$searchcat=($cat_id)?$cat_id:””;
if ($searchcat!=”“){
$searchcat .= subcategories($cat_id); //cat_id='”.$_GET[‘cid’]."’
}

$Dealsquery .= " and cat_id in (".$searchcat.") ";

}
else if($adv_id <> ‘’)
{
$Dealsquery= $Dealsquery . " and webservice_id in (select id from rim_advertisers where name like ‘%" . $adv_id . "%’)“;
}
else if ($searchcnt <> ‘’)
{
$searchquery= " and (product_name like '%” . $searchcnt .“%') “;
}
$tempqry = $Dealsquery;
$Dealsquery= $Dealsquery . $searchquery ;
//echo $Dealsquery;
$nbDeals=getSqlNumber($Dealsquery);
//echo $nbDeals;
if($nbDeals <= 0){
if ($searchcnt <> ‘’)
{
$searchquery= " and (title like '%” . $searchcnt .”%') “;
}
$Dealsquery= $tempqry . $searchquery;
//echo $Dealsquery;
$nbDeals=getSqlNumber($Dealsquery);
}
if($homepage == “true”)
{
$Dealsquery= $Dealsquery . " limit $limit”;
}
//echo $Dealsquery;
$nbDeals=getSqlNumber($Dealsquery);
if($traceenable==true){fwrite($fh, $Dealsquery. "
");}
if($nbDeals > 0){
$getDealsQuery=mysql_query($Dealsquery);

while($item=mysql_fetch_assoc($getDealsQuery)){						
	//$getDeals[$idx] = $item;
	if ($item['regular_price'] != 0)
	{
		$DealsArray[$idx]['prows_price'] = "$" . $item['regular_price'];
		$item['how_much_saving'] = (int) (((float) $item['rebate'] / (float) $item['regular_price']) * 100);
	}
	if ($item['sale_price'] != 0)
	{
		$DealsArray[$idx]['sale_price'] = "$" . $item['sale_price'];
	}
	$DealsArray[$idx]['prod_id'] = $item['product_id'];
	//echo $item['description'];
	$DealsArray[$idx]['prows_description'] = $item['description'];

//MF Build up link on title
//If the title field is empty, then use the product name
//print_r($item);
//echo “p”.$item[‘product_name’];
if ($item[‘title’] <> ‘’)
{
$DealsArray[$idx][‘prows_title’]=$item[‘title’];
}
else if ($item[‘product_name’] <> ‘’)
{
$DealsArray[$idx][‘prows_title’]=$item[‘product_name’];
}

	else
	{
		$DealsArray[$idx]['prows_title']=$item['description'];  
	}
	$DealsArray[$idx]['prows_url'] = $item['go_link'];
	$DealsArray[$idx]['title_link']=html_entity_decode($item["title_link"]);
	//echo $DealsArray[$idx]['title_link'];
	$DealsArray[$idx]['prows_image'] = $item['image'];

//MF End of link on title mod echo “hh”;
$DealsArray[$idx][‘type’] = “Deal”;
$DealsArray[$idx][‘specialnote’] = $item[‘specialnote’];
$DealsArray[$idx][‘shipping_desc’] = $item[‘shipping_desc’];
$DealsArray[$idx][‘imp_url’] = $item[‘imp_url’];
$DealsArray[$idx][‘source’] = $item[‘source’];
$DealsArray[$idx][‘table’] = “rim_product”;
$strAdv = “select name from rim_advertisers WHERE id = '” . $item[‘webservice_id’] . “'”;
//echo $strAdv;
$AdvRow = getSqlRow($strAdv);
$DealsArray[$idx][‘Advertiser’] = $AdvRow[‘name’];

	$idx++;				
}

}

//Amazon Browse Node Listings
$sqlstr = “SELECT * FROM Tbl_Deals_ws WHERE prows_status=1 and sale_price<>‘Too low to display’”;//order by cat_id,prows_asin";//Advertiser <> ‘Amazon’
if ($cat_id <> ‘’)
{
$searchcat=($cat_id)?$cat_id:“”;
if ($searchcat!=“”){
$searchcat .= subcategories($cat_id); //cat_id=‘“.$_GET[‘cid’].”’
}

$sqlstr .= " and cat_id in (".$searchcat.") ";

}
else if($adv_id <> ‘’)
{
$sqlstr= $sqlstr . " and advertiser like ‘%" . $adv_id . "%’“;
}
else
{
}
if ($searchcnt <> ‘’)
{
$sqlstr .= " and prows_title like '%” . $searchcnt ."%’ ";
}

if($homepage == “true”)
{
$sqlstr= $sqlstr . " limit $limit";
}
$rowcnt = getSqlNumber($sqlstr);
$nbDeals += $rowcnt;
//echo “amazon”. $rowcnt . ‘<br>’;
//echo $sqlstr;
if($traceenable==true){
fwrite($fh, $sqlstr. "
");}
if ($rowcnt > 0)
{
//echo $sqlstr;

$getDealsQuery=mysql_query($sqlstr);
while($item=mysql_fetch_assoc($getDealsQuery))
{
	$DealsArray[$idx]['prows_image'] = $item['prows_image'];
	//echo $DealsArray['prows_image'] ;
	$DealsArray[$idx]['prows_title'] = $item['prows_title'];
	$DealsArray[$idx]['prows_url'] = $item['prows_url'];
	$DealsArray[$idx]['prows_image'] = $item['prows_image'];
	$DealsArray[$idx]['prows_description'] = $item['prows_description'];
	if (substr($item['prows_price'],0,1) == "$"){
		$DealsArray[$idx]['prows_price'] = $item['prows_price'];
	}else
	{
		$DealsArray[$idx]['prows_price'] = "$" . $item['prows_price'] ;
	}
	if (substr($item['sale_price'],0,1) == "$"){
		$DealsArray[$idx]['sale_price'] = $item['sale_price'];}
	else{
		$DealsArray[$idx]['sale_price'] = "$" . $item['sale_price'];
	}
	$DealsArray[$idx]['specialnote'] = $item['specialnote'];
	$DealsArray[$idx]['shipping_desc'] = $item['shipping_desc'];
	$DealsArray[$idx]['Advertiser'] = $item['Advertiser'];
	$DealsArray[$idx]['prod_id'] = $item['prows_id'];
	$DealsArray[$idx]['imp_url'] = $item['imp_url'];
	$DealsArray[$idx]['source'] = $item['source'];
	$DealsArray[$idx]['type'] = "Deal";
	$DealsArray[$idx]['table'] = "tbl_deals_ws";
	$idx++;
}

}

//Amazon Gold Deals
$sqlstr = " select * from deals_ws where Advertiser=‘Amazon’ and (Percentage > 10 and Percentage < 100) and Percentage is not null";
if($adv_id <> ‘’)
{
$sqlstr= $sqlstr . " and advertiser like (‘%" . $adv_id . "%’)“;
}
//echo $catsort;
//print_r($keywords);
else if ($cat_id<>‘’)
{
$sqlstr .= " and (”;
$tempcat = $cat_id;
$catsort = “”;
while(list($key,$val)=each($keywords)){
//echo $val;
if($val<>" " and strlen($val) > 0){$catsort .= " description like ‘%" . ltrim($val) . "%’ or ";}

		}// end of while
		$catsort=substr($catsort,0,(strlen($catsort)-3));
		$sqlstr= $sqlstr .  $catsort . ")" ;
		if ($catsort&lt;&gt;'')
		{
		//$cat_id = "";
		}
		reset($keywords);
	}
	if ($searchcnt &lt;&gt; '')
	{
		$sqlstr .= " and title like '%" . $searchcnt ."%' ";
	}
	if($homepage == "true")
	{
		$sqlstr= $sqlstr . " limit $limit";
	}
	//echo $cat_id;
	$rowcnt = getSqlNumber($sqlstr);
	$nbDeals += $rowcnt;

// echo “non amazon”. $rowcnt . ‘<br>’;
//echo $sqlstr;
if($traceenable==true){
fwrite($fh, $sqlstr. "
");}
if ($rowcnt > 0)
{
$getDealsQuery=mysql_query($sqlstr);
while($item=mysql_fetch_assoc($getDealsQuery)){
//print_r($item);
$DealsArray[$idx][‘prows_image’] = $item[‘Image’];

			//echo $item['Image'];//$DealsArray['prows_image'] ;
			$DealsArray[$idx]['prows_description'] = $item['description'];
			$DealsArray[$idx]['prows_title'] = $item['title'];
			if ($item['link'] &lt;&gt; ''){
			$DealsArray[$idx]['prows_url'] = $item['link'];
			}else{
			$DealsArray[$idx]['prows_url'] = $item['guid'];
			}
			if ($item['dealtype'] == "Deal")
			{
				if (substr($item['ListPrice'],0,1) == "$"){
					$DealsArray[$idx]['prows_price'] = $item['ListPrice'];
				}else
				{
					$DealsArray[$idx]['prows_price'] = "$" . $item['ListPrice'];
				}
				$DealsArray[$idx]['rebate'] =  $item['Percentage'] ;
			}
			$DealsArray[$idx]['type'] = $item['dealtype'];
			//echo $item['dealtype'];
			$DealsArray[$idx]['Advertiser'] = $item['Advertiser'];
			if (substr($item['DealPrice'],0,1) == "$"){
				$DealsArray[$idx]['sale_price'] = $item['DealPrice'];}
			else{
				$DealsArray[$idx]['sale_price'] = "$" . $item['DealPrice'];
			}
			//$DealsArray[$idx]['sale_price'] = $item['DealPrice'];
			$DealsArray[$idx]['specialnote'] = $item['specialnote'];
			$DealsArray[$idx]['shipping_desc'] = $item['shipping_desc'];
			$DealsArray[$idx]['prod_id'] = $item['id'];
			$idx++;
	// $DealsArray[$idx]['prows_image'] = $item['prows_image'];
	// $DealsArray[$idx]['prows_description'] = $item['prows_description'];
	// $DealsArray[$idx]['prows_price'] = $item['prows_price'];
	// $DealsArray[$idx]['sale_price'] = $item['sale_price'];
	// $DealsArray[$idx]['specialnote'] = $item['specialnote'];
	// $DealsArray[$idx]['shipping_desc'] = $item['shipping_desc'];
	// $DealsArray[$idx]['Advertiser'] = $item['Advertiser'];
	// $DealsArray[$idx]['type'] = "Deal";
		}
	}
	$cat_id=$tempcat;

//Amazon Gold Deals Promotions
$sqlstr = " select * from deals_ws where dealtype like ‘promo%’ and Advertiser=‘Amazon’“; //and
if($adv_id <> ‘’)
{
$sqlstr= $sqlstr . " and advertiser like ('%” . $adv_id . “%')”;
}
//echo $catsort;
//print_r($keywords);
else if ($cat_id<>‘’)
{
$sqlstr .= " and (“;
$tempcat = $cat_id;
$catsort = “”;
while(list($key,$val)=each($keywords)){
//echo $val;
if($val<>” " and strlen($val) > 0){$catsort .= " description like ‘%" . ltrim($val) . "%’ or ";}

		}// end of while
		$catsort=substr($catsort,0,(strlen($catsort)-3));
		$sqlstr= $sqlstr .  $catsort . ")";
		if ($catsort&lt;&gt;'')
		{
		//$cat_id = "";
		}
		reset($keywords);
	}
	if ($searchcnt &lt;&gt; '')
	{
		$sqlstr .= " and title like '%" . $searchcnt ."%' ";
	}
	if($homepage == "true")
	{
		$sqlstr= $sqlstr . " limit $limit";
	}
	//echo $cat_id;
	$rowcnt = getSqlNumber($sqlstr);
	$nbDeals += $rowcnt;
	//echo "non amazon". $rowcnt . '&lt;br&gt;';
	//echo $sqlstr;
	if($traceenable==true){
	fwrite($fh, $sqlstr. "\

");}

	if ($rowcnt &gt; 0)
	{
		$getDealsQuery=mysql_query($sqlstr);
		while($item=mysql_fetch_assoc($getDealsQuery)){	
			//print_r($item);
			$DealsArray[$idx]['prows_image'] = $item['Image'];
			//echo $item['Image'];//$DealsArray['prows_image'] ;
			$DealsArray[$idx]['prows_description'] = $item['description'];
			$DealsArray[$idx]['prows_title'] = $item['title'];
			if ($item['link'] &lt;&gt; ''){
			$DealsArray[$idx]['prows_url'] = $item['link'];
			}else{
			$DealsArray[$idx]['prows_url'] = $item['guid'];
			}
			if ($item['dealtype'] == "Deal")
			{
				if (substr($item['ListPrice'],0,1) == "$"){
					$DealsArray[$idx]['prows_price'] = $item['ListPrice'];
				}else
				{
					$DealsArray[$idx]['prows_price'] = "$" . $item['ListPrice'];
				}
				$DealsArray[$idx]['rebate'] =  $item['Percentage'] ;
			}
			$DealsArray[$idx]['type'] = $item['dealtype'];
			//echo $item['dealtype'];
			$DealsArray[$idx]['Advertiser'] = $item['Advertiser'];
			if ($item['Image'] == ''){
				$query = "select Logo,Link from `rim_advertisers` where name = '" . $DealsArray[$idx]['Advertiser'] . "'";
				//echo $query;
				$getAdvertiser=mysql_query($query);
				$Adv=mysql_fetch_assoc($getAdvertiser);
				$DealsArray[$idx]['logoimage'] = $Adv['Logo'];
			}
			if (substr($item['DealPrice'],0,1) == "$"){
				$DealsArray[$idx]['sale_price'] = $item['DealPrice'];}
			else{
				$DealsArray[$idx]['sale_price'] = "$" . $item['DealPrice'];
			}
			//$DealsArray[$idx]['sale_price'] = $item['DealPrice'];
			$DealsArray[$idx]['specialnote'] = $item['specialnote'];
			$DealsArray[$idx]['shipping_desc'] = $item['shipping_desc'];
			$DealsArray[$idx]['prod_id'] = $item['id'];

			$idx++;
	// $DealsArray[$idx]['prows_image'] = $item['prows_image'];
	// $DealsArray[$idx]['prows_description'] = $item['prows_description'];
	// $DealsArray[$idx]['prows_price'] = $item['prows_price'];
	// $DealsArray[$idx]['sale_price'] = $item['sale_price'];
	// $DealsArray[$idx]['specialnote'] = $item['specialnote'];
	// $DealsArray[$idx]['shipping_desc'] = $item['shipping_desc'];
	// $DealsArray[$idx]['Advertiser'] = $item['Advertiser'];
	// $DealsArray[$idx]['type'] = "Deal";
		}
	}
	$cat_id=$tempcat;

//Non Amazon Gold Deals Promotions
$sqlstr = " select * from deals_ws where dealtype like ‘promo%’ and Advertiser<>‘Amazon’“; //and
if($adv_id <> ‘’)
{
$sqlstr= $sqlstr . " and advertiser like ('%” . $adv_id . “%')”;
}
//echo $catsort;
//print_r($keywords);
else if ($cat_id<>‘’)
{
$sqlstr .= " and (“;
$tempcat = $cat_id;
$catsort = “”;
while(list($key,$val)=each($keywords)){
//echo $val;
if($val<>” " and strlen($val) > 0){$catsort .= " description like ‘%" . ltrim($val) . "%’ or ";}

		}// end of while
		$catsort=substr($catsort,0,(strlen($catsort)-3));
		$sqlstr= $sqlstr .  $catsort . ")";
		if ($catsort&lt;&gt;'')
		{
		//$cat_id = "";
		}
		reset($keywords);
	}
	if ($searchcnt &lt;&gt; '')
	{
		$sqlstr .= " and title like '%" . $searchcnt ."%' ";
	}
	if($homepage == "true")
	{
		$sqlstr= $sqlstr . " limit $limit";
	}
	//echo $cat_id;
	$rowcnt = getSqlNumber($sqlstr);
	$nbDeals += $rowcnt;
	//echo "non amazon". $rowcnt . '&lt;br&gt;';
	//echo $sqlstr;
	if($traceenable==true){
	fwrite($fh, $sqlstr. "\

");}

	if ($rowcnt &gt; 0)
	{
		$getDealsQuery=mysql_query($sqlstr);
		while($item=mysql_fetch_assoc($getDealsQuery)){	
			//print_r($item);
			$DealsArray[$idx]['prows_image'] = $item['Image'];
			//echo $item['Image'];//$DealsArray['prows_image'] ;
			$DealsArray[$idx]['prows_description'] = $item['description'];
			$DealsArray[$idx]['prows_title'] = $item['title'];
			if ($item['link'] &lt;&gt; ''){
			$DealsArray[$idx]['prows_url'] = $item['link'];
			}else{
			$DealsArray[$idx]['prows_url'] = $item['guid'];
			}
			if ($item['dealtype'] == "Deal")
			{
				if (substr($item['ListPrice'],0,1) == "$"){
					$DealsArray[$idx]['prows_price'] = $item['ListPrice'];
				}else
				{
					$DealsArray[$idx]['prows_price'] = "$" . $item['ListPrice'];
				}
				$DealsArray[$idx]['rebate'] =  $item['Percentage'] ;
			}
			$DealsArray[$idx]['type'] = $item['dealtype'];
			//echo $item['dealtype'];
			$DealsArray[$idx]['Advertiser'] = $item['Advertiser'];
			if ($item['Image'] == ''){
				$query = "select Logo,Link from `rim_advertisers` where name = '" . $DealsArray[$idx]['Advertiser'] . "'";
				//echo $query;
				$getAdvertiser=mysql_query($query);
				$Adv=mysql_fetch_assoc($getAdvertiser);
				$DealsArray[$idx]['logoimage'] = $Adv['Logo'];
			}
			if (substr($item['DealPrice'],0,1) == "$"){
				$DealsArray[$idx]['sale_price'] = $item['DealPrice'];}
			else{
				$DealsArray[$idx]['sale_price'] = "$" . $item['DealPrice'];
			}
			//$DealsArray[$idx]['sale_price'] = $item['DealPrice'];
			$DealsArray[$idx]['specialnote'] = $item['specialnote'];
			$DealsArray[$idx]['shipping_desc'] = $item['shipping_desc'];
			$DealsArray[$idx]['prod_id'] = $item['id'];
			$DealsArray[$idx]['expiry'] = $item['expirydate'];
			$idx++;
	// $DealsArray[$idx]['prows_image'] = $item['prows_image'];
	// $DealsArray[$idx]['prows_description'] = $item['prows_description'];
	// $DealsArray[$idx]['prows_price'] = $item['prows_price'];
	// $DealsArray[$idx]['sale_price'] = $item['sale_price'];
	// $DealsArray[$idx]['specialnote'] = $item['specialnote'];
	// $DealsArray[$idx]['shipping_desc'] = $item['shipping_desc'];
	// $DealsArray[$idx]['Advertiser'] = $item['Advertiser'];
	// $DealsArray[$idx]['type'] = "Deal";
		}
	}
	$cat_id=$tempcat;

//LinkShare
$sqlstr = " select * from deals_ws where (Advertiser<>‘Amazon’ and Advertiser<>‘Ebay’) and (Percentage > 10 and Percentage <= 100)“;
if($adv_id <> ‘’)
{
$sqlstr= $sqlstr . " and advertiser like '%” . $adv_id . “%'”;
}
if ($cat_id<>‘’)
{
$sqlstr .= " and (“;
$tempcat = $cat_id;
$catsort = “”;
while(list($key,$val)=each($keywords))
{
//echo $val;
if($val<>” " and strlen($val) > 0){$catsort .= " description like ‘%" . ltrim($val) . "%’ or “;}
}// end of while
$catsort=substr($catsort,0,(strlen($catsort)-3));
$sqlstr= $sqlstr . $catsort . “)”;
if ($catsort<>‘’)
{
// $cat_id = “”;
}
reset($keywords);
}
if ($searchcnt <> ‘’)
{
$sqlstr .= " and title like '%” . $searchcnt ."%’ “;
}
if($homepage == “true”)
{
$sqlstr= $sqlstr . " limit $limit”;
}
$rowcnt = getSqlNumber($sqlstr);

	$nbDeals += $rowcnt;
	if($traceenable==true){
	fwrite($fh, $sqlstr. "\

");}
//echo “no amazon”. $rowcnt . ‘<br>’;
//echo $sqlstr;
if ($rowcnt > 0)
{
$getDealsQuery=mysql_query($sqlstr);
while($item=mysql_fetch_assoc($getDealsQuery)){
//print_r($item);
$DealsArray[$idx][‘prows_image’] = $item[‘Image’];

			//echo $item['Image'];//$DealsArray['prows_image'] ;
			$DealsArray[$idx]['prows_description'] = $item['description'];
			$DealsArray[$idx]['prows_title'] = $item['title'];
			$DealsArray[$idx]['prows_url'] = $item['guid'];
			if ($item['dealtype'] == "Deal")
			{
				if (substr($item['ListPrice'],0,1) == "$"){
					$DealsArray[$idx]['prows_price'] = $item['ListPrice'];
				}else
				{
					$DealsArray[$idx]['prows_price'] = "$" . $item['ListPrice'];
				}

				//$DealsArray[$idx]['prows_price'] = $item['ListPrice'] ;
				$DealsArray[$idx]['rebate'] =  $item['Percentage'] ;
			}
			$DealsArray[$idx]['type'] = $item['dealtype'];
			$DealsArray[$idx]['Advertiser'] = $item['Advertiser'];
			if (substr($item['DealPrice'],0,1) == "$"){
				$DealsArray[$idx]['sale_price'] = $item['DealPrice'];}
			else{
				$DealsArray[$idx]['sale_price'] = "$" . $item['DealPrice'];
			}
			//$DealsArray[$idx]['sale_price'] = $item['DealPrice'];
			$DealsArray[$idx]['specialnote'] = $item['specialnote'];
			$DealsArray[$idx]['shipping_desc'] = $item['shipping_desc'];
			$DealsArray[$idx]['source'] = "";
			$DealsArray[$idx]['prod_id'] = $item['id'];

			$idx++;
	// $DealsArray[$idx]['prows_image'] = $item['prows_image'];
	// $DealsArray[$idx]['prows_description'] = $item['prows_description'];
	// $DealsArray[$idx]['prows_price'] = $item['prows_price'];
	// $DealsArray[$idx]['sale_price'] = $item['sale_price'];
	// $DealsArray[$idx]['specialnote'] = $item['specialnote'];
	// $DealsArray[$idx]['shipping_desc'] = $item['shipping_desc'];
	// $DealsArray[$idx]['Advertiser'] = $item['Advertiser'];
	// $DealsArray[$idx]['type'] = "Deal";
		}
	}

$cat_id=$tempcat;

//CJ Coupons
$Couponquery=“SELECT * FROM rim_coupon where status=1 and description2 != ‘Banner’ and shipping_desc=‘Coupons’ “;//AND (exp_date > now() OR exp_date=‘0000-00-00’) “;and advertiser = '” . $advDetails[‘advertiser’] . “’
if($adv_id <> ‘’)
{
$Couponquery= $Couponquery . " and advertiser like '%” . $adv_id . “%'”;
}
//echo $Couponquery;
else{
//$Couponquery.=” order by rand() limit $start,$limit”;
}
if ($searchcnt <> ‘’)
{
$Couponquery .= " and name like ‘%" . $searchcnt ."%’ “;
}
if ($cat_id<>‘’)
{
$Couponquery .= " and (”;
$tempcat = $cat_id;
$catsort = “”;
while(list($key,$val)=each($keywords)){
//echo $val;
if($val<>" " and strlen($val) > 0){$catsort .= " description like ‘%" . ltrim($val) . "%’ or “;}
}// end of while
$catsort=substr($catsort,0,(strlen($catsort)-3));
$Couponquery= $Couponquery . $catsort . “)”;
if ($catsort<>‘’)
{
// $cat_id = “”;
}
reset($keywords);
}
if($homepage == “true”)
{
$Couponquery= $Couponquery . " limit $limit”;
}
$nbCoupon=getSqlNumber($Couponquery);
if ($cat_id == ‘’)
{
$nbDeals += $nbCoupon;
}

$count=0;

//echo "coupons". $nbCoupon . '&lt;br&gt;';
//echo $Couponquery;
if($traceenable==true){
	fwrite($fh, $Couponquery. "\

");}
if($nbCoupon>0) {
$getCoupon=mysql_query($Couponquery);
while($item=mysql_fetch_assoc($getCoupon)){
$DealsArray[$idx][‘prod_id’] = $item[‘cid’];
$DealsArray[$idx][‘prows_description’] = $item[‘description’];
$DealsArray[$idx][‘prows_title’] = $item[‘name’];
$DealsArray[$idx][‘prows_url’] = $item[‘title_link’];
if ($item[‘shipping_desc’] == “Coupons”)
{
$DealsArray[$idx][‘type’] = $item[‘shipping_desc’];
$DealsArray[$idx][‘couponno’] = $item[‘coupon_no’];
//$DealsArray[$idx][‘prows_price’] = $item[‘ListPrice’] ;
//$DealsArray[$idx][‘rebate’] = $item[‘Percentage’] ;
}
else
{
$DealsArray[$idx][‘type’] = “Promotion”;
$DealsArray[$idx][‘shipping_desc’] = $item[‘shipping_desc’];
}

		$DealsArray[$idx]['Advertiser'] = $item['advertiser'];
		$query = "select Logo,Link from `rim_advertisers` where name = '" . $DealsArray[$idx]['Advertiser'] . "'";
		//echo $query;
		$getAdvertiser=mysql_query($query);
		$Adv=mysql_fetch_assoc($getAdvertiser);
		//echo $Adv['Logo'];
		$DealsArray[$idx]['logolink'] = $Adv['Link'];
		$DealsArray[$idx]['source'] = $item['source'];
		//echo $DealsArray[$idx]['source'];
		$DealsArray[$idx]['logoimage'] = $Adv['Logo'];//"http://www.tqlkg.com/m4115c37w1-LOMTPRTNLNMOVPQNN";
		// if ($DealsArray[$idx]['Advertiser'] == "eBags")
		// {
			// //echo "eBags";
			// $DealsArray[$idx]['logolink'] = "http://www.kqzyfj.com/c2111uoxuowBECJFHJDBDCELFGDD";
			
			// $DealsArray[$idx]['logoimage'] = "http://www.tqlkg.com/m4115c37w1-LOMTPRTNLNMOVPQNN";
		// }
		
		// else if (substr($DealsArray[$idx]['Advertiser'],0,2) == "HP")// Home & Home Office Store")
		// {
			// ///echo "HP";
			// $DealsArray[$idx]['logolink'] = "http://www.anrdoezrs.net/ch103uoxuowBECJFHJDBDCGEFLKG";
			// $DealsArray[$idx]['logoimage'] = "http://www.lduhtrp.net/h4102drvjpn8B9GCEGA8A9DBCIHD";
			// $DealsArray[$idx]['logoimage1'] = '&lt;a href="http://www.anrdoezrs.net/ch103uoxuowBECJFHJDBDCGEFLKG" target="_blank"&gt;&lt;img src="http://www.lduhtrp.net/h4102drvjpn8B9GCEGA8A9DBCIHD" alt="" border="0"/&gt;&lt;/a&gt;';
		// }
		// else if ($DealsArray[$idx]['Advertiser'] == "NewEgg.com")
		// {
			// //echo "NewEgg";
			// $DealsArray[$idx]['logolink'] = "http://www.tkqlhce.com/ij98ar-xrzEHFMIKMGEGFJJFKKN";
			
			// $DealsArray[$idx]['logoimage'] = "http://www.awltovhc.com/m1116g04tzxILJQMOQKIKJNNJOOR";
		// }
		// else if ($DealsArray[$idx]['Advertiser'] == "123Inkjets.com")
		// {
			// $DealsArray[$idx]['logolink'] = "http://www.kqzyfj.com/qq83gv30v2ILJQMOQKIKJLSRLSL";
			
			// $DealsArray[$idx]['logoimage'] = "http://www.lduhtrp.net/5f108xjnbhf031846820213A93A3";
		// }
		$DealsArray[$idx]['expiry'] = $item['expiry'];
		$idx++;
		//echo $item['shipping_desc'];
	}
}

//CJ Promotions
$Couponquery=“SELECT * FROM rim_coupon where status=1 and description2 != ‘Banner’ and shipping_desc<>‘Coupons’ “;//AND (exp_date > now() OR exp_date=‘0000-00-00’) “;and advertiser = '” . $advDetails[‘advertiser’] . “’
if($adv_id <> ‘’)
{
$Couponquery= $Couponquery . " and advertiser like '%” . $adv_id . “%'”;
}
else
{
}
if ($searchcnt <> ‘’)
{
$Couponquery .= " and name like '%” . $searchcnt .”%’ “;
}
if ($cat_id<>‘’)
{
$Couponquery .= " and (”;
$tempcat = $cat_id;
$catsort = “”;
// print_r($keywords);
while(list($key,$val)=each($keywords)){
// echo “here”. $key;
if($val<>" " and strlen($val) > 0){$catsort .= " description like ‘%" . ltrim($val) . "%’ or ";}
}// end of while
// echo $catsort;
$catsort=substr($catsort,0,(strlen($catsort)-3));
$Couponquery= $Couponquery . $catsort . “)”;
if ($catsort<>‘’)
{
// $cat_id = “”;
}
reset($keywords);
}

	if($homepage == "true")
	{
		$Couponquery= $Couponquery . " limit $limit";
	}

// echo $Couponquery;
if($traceenable==true){
fwrite($fh, $Couponquery. "
");}
$nbCoupon=getSqlNumber($Couponquery);
if ($cat_id == ‘’)
{
$nbDeals += $nbCoupon;
}
//echo “promos”. $nbCoupon . ‘<br>’;

//$Couponquery.=" order by rand() limit $start,$limit";

$count=0;
//echo $Couponquery;
if($nbCoupon&gt;0) {					 
	$getCoupon=mysql_query($Couponquery);
	while($item=mysql_fetch_assoc($getCoupon)){
		$DealsArray[$idx]['prod_id'] = $item['cid'];
		//$DealsArray[$idx]['prows_image'] = $item['Image'];
		$DealsArray[$idx]['prows_description'] = $item['description'];
		$DealsArray[$idx]['prows_title'] = $item['name'];
		$DealsArray[$idx]['prows_url'] = $item['title_link'];
		if ($item['shipping_desc'] == "Coupons")
		{
			$DealsArray[$idx]['type'] = $item['shipping_desc'];
			$DealsArray[$idx]['couponno'] = $item['coupon_no'];
			//$DealsArray[$idx]['prows_price'] = $item['ListPrice'] ;
			//$DealsArray[$idx]['rebate'] =  $item['Percentage'] ;
		}
		else
		{
			$DealsArray[$idx]['type'] = "Promotion";
			$DealsArray[$idx]['shipping_desc'] = $item['shipping_desc'];
		}
		
		$DealsArray[$idx]['Advertiser'] = $item['advertiser'];
		$query = "select Logo,Link from `rim_advertisers` where name = '" . $DealsArray[$idx]['Advertiser'] . "'";
		//echo $query;
		$getAdvertiser=mysql_query($query);
		$Adv=mysql_fetch_assoc($getAdvertiser);
		$DealsArray[$idx]['logolink'] = $Adv['Link'];
		//echo $Adv['Logo'];
		$DealsArray[$idx]['logoimage'] = $Adv['Logo'];
		$DealsArray[$idx]['date'] = $item['datestr'];
		$DealsArray[$idx]['expiry'] = $item['expiry'];
		$DealsArray[$idx]['source'] = $item['source'];
		$idx++;
		//echo $item['shipping_desc'];
	}
}

//Ebay Deals
$sqlstr = " select * from deals_ws where Advertiser=‘Ebay’ and (Percentage > 10 and Percentage < 100)“;
if($adv_id <> ‘’)
{
$sqlstr= $sqlstr . " and advertiser like '%” . $adv_id . “%'”;
}
else if ($cat_id<>‘’)
{
$sqlstr .= " and (“;
$tempcat = $cat_id;
$catsort = “”;
while(list($key,$val)=each($keywords)){
//echo $val;
if($val<>” " and strlen($val) > 0){$catsort .= " description like ‘%" . ltrim($val) . "%’ or ";}

		}// end of while
		$catsort=substr($catsort,0,(strlen($catsort)-3));
		$sqlstr= $sqlstr .  $catsort . ")" ;
		if ($catsort&lt;&gt;'')
		{

// $cat_id = “”;
}
reset($keywords);

	}
	if ($searchcnt &lt;&gt; '')
	{
		$sqlstr .= " and title like '%" . $searchcnt ."%' ";
	}
	if($homepage == "true")
	{
		$sqlstr= $sqlstr . " limit $limit";
	}
	$rowcnt = getSqlNumber($sqlstr);
	$nbDeals += $rowcnt;

// echo $sqlstr . “ebay”. $rowcnt . ‘<br>’;
if($traceenable==true){
fwrite($fh, $sqlstr. "
");}

	if ($rowcnt &gt; 0)
	{
		$getDealsQuery=mysql_query($sqlstr);
		while($item=mysql_fetch_assoc($getDealsQuery)){	
			//print_r($item);
			$DealsArray[$idx]['prows_image'] = $item['Image'];
			
			//echo $item['Image'];//$DealsArray['prows_image'] ;
			$DealsArray[$idx]['prows_description'] = $item['description'];
			$DealsArray[$idx]['prows_title'] = $item['title'];
			$DealsArray[$idx]['prows_url'] = $item['link'];
			if ($item['dealtype'] == "Deal")
			{
				if (substr($item['ListPrice'],0,1) == "$"){
					$DealsArray[$idx]['prows_price'] = $item['ListPrice'];
				}else
				{
					$DealsArray[$idx]['prows_price'] = "$" . $item['ListPrice'];
				}

				//$DealsArray[$idx]['prows_price'] = $item['ListPrice'] ;
				$DealsArray[$idx]['rebate'] =  $item['Percentage'] ;
			}else{
				//echo $item['dealtype'];
			}
			$DealsArray[$idx]['type'] = $item['dealtype'];
			$DealsArray[$idx]['Advertiser'] = $item['Advertiser'];
			if (substr($item['DealPrice'],0,1) == "$"){
				$DealsArray[$idx]['sale_price'] = $item['DealPrice'];}
			else{
				$DealsArray[$idx]['sale_price'] = "$" . $item['DealPrice'];
			}

			//$DealsArray[$idx]['sale_price'] = $item['DealPrice'];
			$DealsArray[$idx]['specialnote'] = $item['specialnote'];
			$DealsArray[$idx]['shipping_desc'] = $item['shipping_desc'];
			$DealsArray[$idx]['prod_id'] = $item['id'];

			$idx++;
	// $DealsArray[$idx]['prows_image'] = $item['prows_image'];
	// $DealsArray[$idx]['prows_description'] = $item['prows_description'];
	// $DealsArray[$idx]['prows_price'] = $item['prows_price'];
	// $DealsArray[$idx]['sale_price'] = $item['sale_price'];
	// $DealsArray[$idx]['specialnote'] = $item['specialnote'];
	// $DealsArray[$idx]['shipping_desc'] = $item['shipping_desc'];
	// $DealsArray[$idx]['Advertiser'] = $item['Advertiser'];
	// $DealsArray[$idx]['type'] = "Deal";
		}
	}

foreach($DealsArray as $getdeals)
{
if($getdeals[‘advertiser’] == “eBay”)
{
$getdeals[‘prows_image’] = fix_amazon_image_size($getdeals[‘prows_image’], EBAY_IMAGE_SIZE);
}
else{
$getdeals[‘prows_image’] = fix_amazon_image_size($getdeals[‘prows_image’], AMAZON_IMAGE_SIZE);
}

if($getdeals['type'] == "Deal")
{
	$gDealArray[$gDealCount] = $getdeals;
	//print_r($gDealArray[$gDealCount]);
	$gDealCount++;

}
if($getdeals['type'] == "Coupons")
{
	$gCouponArray[$gCouponCount] = $getdeals;
	$gCouponCount++;
}
if($getdeals['type'] == "Promotion")
{
	$gPromotionArray[$gPromotionCount] = $getdeals;
	$gPromotionCount++;
}
//$getdeals['prows_description'] = str_replace("'","",$getdeals['prows_description']);
//$getdeals['prows_title'] = str_replace("'","",$getdeals['prows_title']);
//$getdeals['specialnote'] = str_replace("'","",$getdeals['specialnote']);
//$getdeals['shipping_desc'] = str_replace("'","",$getdeals['shipping_desc']);
//$getdeals['title_link'] = str_replace("'","",$getdeals['title_link']);
//$getdeals['prows_description'] = str_replace(chr(34),"",$getdeals['prows_description']);
//$getdeals['prows_title'] = str_replace(chr(34),"",$getdeals['prows_title']);
//$getdeals['specialnote'] = str_replace(chr(34),"",$getdeals['specialnote']);
//$getdeals['shipping_desc'] = str_replace(chr(34),"",$getdeals['shipping_desc']);
//$getdeals['title_link'] = str_replace(chr(34),"",$getdeals['title_link']);		
//$getdeals['sessionid'] = session_id();
//$sql = "SELECT 1 FROM extract_products " . "WHERE prod_id = '{$getdeals['prod_id']}' " . " AND sessionid = '{$getdeals['sessionid']}'";
//			if (getSqlNumber($sql) != 0)
//			{
//				continue;
//			}

//$sqls = "INSERT INTO extract_products( `prows_price` , `sale_price` , `prod_id` , `prows_description` , `prows_title` , `prows_url` , `title_link` , `prows_image` , `prodtype` , `specialnote` , `shipping_desc` , `imp_url` , `source` , `table_id` , `Advertiser` , `logolink` , `logoimage` , `c_date` , `expiry` , `sessionid` ) values(";
//$sqls = $sqls . "'" . $getdeals['prows_price'] . "','" . $getdeals['sale_price'] . "','" . $getdeals['prod_id'] . "','" . $getdeals['prows_description'] . "','" . $getdeals['prows_title'] . "','" . $getdeals['prows_url'] . "','" . $getdeals['title_link'] . "','" . $getdeals['prows_image'] . "','" . $getdeals['type'] . "','" . $getdeals['specialnote'] . "','" . $getdeals['shipping_desc'] . "','" . $getdeals['imp_url'] . "','" . $getdeals['source'] . "','" . $getdeals['table_id'] . "','" . $getdeals['Advertiser'] . "','" . $getdeals['logolink'] . "','" . $getdeals['logoimage'] . "','" . $getdeals['date'] . "','" . $getdeals['expiry'] . "','" . $getdeals['sessionid'] . "')";
//echo $sqls;
//exit;
//$insert_id = insertQuery($sqls);

}
shuffle($gPromotionArray);
shuffle($gDealArray);
$_SESSION[‘gDealArray’] = $gDealArray;
$_SESSION[‘gPromotionArray’] = $gPromotionArray;
$_SESSION[‘gAllArray’] = $DealsArray;
//print_r($gDealArray);
if($traceenable==true){
fclose($fh);}
?>

That’s not the total code as you have a ton of includes that could be causing the problem, and, not to sound like a jerk but I just don’t have time to go through all of that code, there’s just too much.

I’m thinking post #7 is what you need to look at again. Or, maybe you need to look at your pagination and just perform a query on each page instead of storing it in a SESSION. You have a lot going on there and it’s quite possible you’re just running out of memory.

Also, what I would most likely do is just run through the basic steps of troubleshooting. Comment out everything that’s irrelevant to your problem and see if it works. If it does, then start adding things back in until it breaks.

i have a question here.!!!
if we have the memory issue it shuld not work in any page with any sort
b’coz i am using the same logic with all the queries
I don’t agree with u it’s a memory issue.

and include files are there.
shuld we add session_start() in all pages
i added and saw anyway!

That reasoning is not correct. If it’s a memory issue it may very well be that it works on one page and not another. If one page only has a few results, and another page has many results, it may be that the page with the small results will work, but the one with many results won’t.

You can compare this to storing beans in a small jar; if I have a few beans I can put them in there, but I can’t put a lot of beans in there, it just won’t fit.

Anyway, I too am fairly convinced that it’s a memory problem. Storing large amounts of data in the SESSION is never a good idea anyway, exactly for the reason your finding out now …