A
Anonymous
Guest
hi every one,I need an emergency help.If anyone is listening then here is my problem.
I have two pages the search_class.php and search.php,when i invoke the methods defined in the class search_class.php via the search.php I got the above mentioned error.
Below is the detail of those two pages:
search_class.php
<?
##############################################
class paging
{
var $koneksi;
var $p;
var $page;
var $q;
var $query;
var $next;
var $prev;
var $number;
function paging($baris=9, $langkah=9, $prev="[prev]", $next="[next]", $number="[%%number%%]")
{
$this->next=$next;
$this->prev=$prev;
$this->number=$number;
$this->p["baris"]=$baris;
$this->p["langkah"]=$langkah;
$_SERVER["QUERY_STRING"]=preg_replace("/&page=[0-9]*/","",$_SERVER["QUERY_STRING"]);
if (empty($_GET["page"])) {
$this->page=1;
} else {
$this->page=$_GET["page"];
}
}
function db($host,$username,$password,$dbname)
{
$this->koneksi=mysql_connect("localhost", "root","NepalWireLess") or die("Connection Error");
mysql_select_db("Haatbazar");
return $this->koneksi;
}
function query($query)
{
$kondisi=false;
$value=@$_POST["value"];
if($value=='') $value=@$_GET["value"];
$categoryid=@$_POST["categoryid"];
if($categoryid=='') $categoryid=@$_GET["categoryid"];
if($categoryid=='') $categoryid='ALL';
$place=@$_POST["place"];
if($place=='') $place=@$_GET["place"];
if($place=='') $place='ALL';
/*if($value=='')
{
die('<div class="warning">Provide String to search. ');
}*/
/*$query="SELECT item.id
FROM `item` INNER JOIN `ccinfo`
ON item.ccid=ccinfo.ccid
WHERE (
((item.name LIKE '%".$value."%' ) OR (item.description LIKE '%".$value."%' ))
AND ( ccinfo.address LIKE '%".$place."%' )
AND ( item.status != 'Sold' )
)";*/
//$query="select *from item where name='Bhaisi'";
// this->query=$query;
//echo"the passed query is:$query";
//$query="select item.id,item.name,item.price,item.status,item.picture,item.description,ccinfo.address from item,ccinfo,category where item.name='%$value%'AND ccinfo.address='%$place%'AND item.ccid=ccinfo.ccid";
$querytemp = mysql_query($query);
$this->p["count"]= mysql_num_rows($querytemp);
$this->p["total_page"]=ceil($this->p["count"]/$this->p["baris"]);
if ($this->page<=1)
$this->page=1;
elseif ($this->page>$this->p["total_page"])
$this->page=$this->p["total_page"];
$this->p["mulai"]=$this->page*$this->p["baris"]-$this->p["baris"];
if($categoryid=="ALL")
{
//echo"inside query";
$query=$query." limit ".$this->p["mulai"].",".$this->p["baris"];
$query=mysql_query($query) or die("Query Error");
$this->query=$query;
}
else
{
$query=$query." limit ".$this->p["mulai"].",".$this->p["baris"];
$query=mysql_query($query) or die("Query Error");
$this->query=$query;
//echo"inside query1";
}
/*{
echo "<br>function>>database.php>>search";
$con=connectdb();
if($place=='ALL') {
$ccinfo_address='%';
echo 'place = all';
}
else{
$ccinfo_address=$place;
echo 'place != all';
}
if($categoryid=='ALL')
{
$sql="SELECT item.id
FROM `item` INNER JOIN `ccinfo`
ON item.ccid=ccinfo.ccid
WHERE (
((item.name LIKE '%".$value."%' ) OR (item.description LIKE '%".$value."%' ))
AND ( ccinfo.address LIKE '%".$ccinfo_address."%' )
AND ( item.status != 'Sold' )
)";
echo 'category = all';
}
else
{
echo "<br>jasdfksfhasdkfjkasd category != all";
$sql="SELECT item.id
FROM `item` INNER JOIN `ccinfo`
ON item.ccid=ccinfo.ccid
WHERE (
((item.name LIKE '%".$value."%' ) OR (item.description LIKE '%".$value."%' ))
AND ( item.categoryid='".$categoryid."' )
AND ( ccinfo.address LIKE '%".$ccinfo_address."%' )
AND ( item.status != 'Sold' )
)";
}
$result=mysql_query($sql,$con)
or //die($sql.' <div class="error"> ERROR gsdfgsdgwhile searching in database<br>'.mysql_error().'</div>');
die($sql." cannot be executed");
echo 'result = '.$result;
return $result;
}*/
}
function result()
{
echo"inside result function";
return $result=mysql_fetch_object($this->query);
}
function result_assoc()
{
//echo"inside result assoc";
//echo"$this->query";
return mysql_fetch_assoc($this->query);
}
function print_no()
{
$number=$this->p["mulai"]+=1;
return $number;
}
function print_color($color1,$color2)
{
if (empty($this->p["count_color"]))
$this->p["count_color"] = 0;
if ( $this->p["count_color"]++ % 2 == 0 ) {
return $color=$color1;
} else {
return $color=$color2;
}
}
function print_info()
{
$page=array();
$page["start"]=@$this->p["mulai"]+1;
$page["end"]=@$this->p["mulai"]+@$this->p["baris"];
$page["total"]=@$this->p["count"];
$page["total_pages"]=@$this->p["total_page"];
if ($page["end"] > $page["total"]) {
$page["end"]=@$page["total"];
}
if (empty($this->p["count"])) {
$page["start"]=0;
}
return $page;
}
function print_link()
{
//generate template
function number($i,$number)
{
return ereg_replace("^(.*)%%number%%(.*)$","\\1$i\\2",$number);
}
$print_link = false;
if (@$this->p["count"]>@$this->p["baris"]) {
// print prev
if ($this->page>1)
$print_link .= "<a href=\"".$_SERVER["PHP_SELF"]."?".$_SERVER["QUERY_STRING"]."&page=".($this->page-1)."\">".$this->prev."</a>\n";
// set number
$this->p["bawah"]=$this->page-$this->p["langkah"];
if ($this->p["bawah"]<1) $this->p["bawah"]=1;
$this->p["atas"]=$this->page+$this->p["langkah"];
if ($this->p["atas"]>$this->p["total_page"]) $this->p["atas"]=$this->p["total_page"];
// print start
if ($this->page<>1)
{
for ($i=$this->p["bawah"];$i<=$this->page-1;$i++)
$print_link .="<a href=\"".$_SERVER["PHP_SELF"]."?".$_SERVER["QUERY_STRING"]."&page=$i\">".number($i,$this->number)."</a>\n";
}
// print active
if ($this->p["total_page"]>1)
$print_link .= "<b>".number($this->page,$this->number)."</b>\n";
// print end
for ($i=$this->page+1;$i<=$this->p["atas"];$i++)
$print_link .= "<a href=\"".$_SERVER["PHP_SELF"]."?".$_SERVER["QUERY_STRING"]."&page=$i\">".number($i,$this->number)."</a>\n";
// print next
if ($this->page<$this->p["total_page"])
$print_link .= "<a href=\"".$_SERVER["PHP_SELF"]."?".$_SERVER["QUERY_STRING"]."&page=".($this->page+1)."\">".$this->next."</a>\n";
return $print_link;
}
}
}
?>
the code for search.php is as below:
search.php
<?
include("search_class.php");
include("./functions/database.php");
include("./forms/form_search1.php");
$paging=new paging(9,9);
$paging1=new paging(9,9);
session_start();
$value=@$_POST['value'];
$place=@$_POST['place'];
$category=@$_POST['categoryid'];
//To restart a new session when the new entry has been added to the fields for searching//
if((!(@$_POST['value']==""))||(!(@$_POST['place']==""))||(!(@$_POST['categoryid']=="")))
{
session_unregister('test');//unregistering the already registered session
session_unregister('place');
session_unregister('category');
}
if(!(isset($_SESSION['test'])))
{
$_SESSION['test']=@$value;
$_SESSION['place']=@$place;
$_SESSION['category']=@$category;
}
if(!(session_is_registered('test')))
{
session_register('test');
session_register('place');
session_register('category');
$test="test";
session_start(); //start session and initialize the variable if not already done!
$_SESSION['test']=@$value;//setting value of session instead of only value
$_SESSION['place']=@$place;
$_SESSION['category']=@$category;
//session_register($test);
//echo"session not set1";
//echo"$_SESSION[test]";
}
else
{
echo"Search for";
$t=$_SESSION['test'];
echo" $t<br>";
$s=$_SESSION['place'];
//echo"<br>Posted from: $s</br>";
$cat=$_SESSION['category'];
//echo"For the category:$cat<br>";
}
$paging->db("localhost","root","NepalWireLess","Haatbazar");
$paging->query("select item.id,item.name,item.price,item.description,item.status,item.picture,ccinfo.address from item,ccinfo where item.name like'%$t%' and item.ccid=ccinfo.ccid order by item.id desc");
$page=$paging->print_info();
echo "Data $page[start] - $page[end] of $page[total] [Total $page[total_pages] Pages]<hr>\n";
$imagedir='images/itemimages/';
echo "<table border=0 cellspacing=20>";
echo "<tr width=100% height=30>";
$count=1;
while ($result=$paging->result_assoc()) {
$ccid=@$result[ccid];
$paging1->query("select *from ccinfo where ccid='$ccid '");
$result1=$paging1->result_assoc();
echo "<td>";
$image=$result["picture"];
//echo"$imagedir";
echo "<table border=1 >";
echo "<tr><td valign=top width='100%' height=10 align=center class=display1><b>$result[name]</b></td></tr>";
echo "<tr><td valign=top height=200 align=center class=display1><img width=200 height=200 src='$imagedir/$image' alt=$result[description]></td></tr>";
echo "<tr><td align=center class=display2>ID:$result[id]</td></tr>";
echo "<tr><td align=center class=display2>Rs.$result[price]</td></tr>";
echo "<tr><td align=center class=display2>Status:$result[status]</td></tr>";
echo "<tr><td align=center class=display2>Location:$result[address]</td></tr>";
echo "</table>";
echo "</td>";
if(($count%3)==0){
echo "</tr></table><br>";
echo "<table border=0 cellspacing=20>";
echo "<tr width=100% height=30>";
//error_report('0');
}
$count++;
}
echo "</tr></table>";
echo "<hr>".$paging->print_link();
?>
I have two pages the search_class.php and search.php,when i invoke the methods defined in the class search_class.php via the search.php I got the above mentioned error.
Below is the detail of those two pages:
search_class.php
<?
##############################################
class paging
{
var $koneksi;
var $p;
var $page;
var $q;
var $query;
var $next;
var $prev;
var $number;
function paging($baris=9, $langkah=9, $prev="[prev]", $next="[next]", $number="[%%number%%]")
{
$this->next=$next;
$this->prev=$prev;
$this->number=$number;
$this->p["baris"]=$baris;
$this->p["langkah"]=$langkah;
$_SERVER["QUERY_STRING"]=preg_replace("/&page=[0-9]*/","",$_SERVER["QUERY_STRING"]);
if (empty($_GET["page"])) {
$this->page=1;
} else {
$this->page=$_GET["page"];
}
}
function db($host,$username,$password,$dbname)
{
$this->koneksi=mysql_connect("localhost", "root","NepalWireLess") or die("Connection Error");
mysql_select_db("Haatbazar");
return $this->koneksi;
}
function query($query)
{
$kondisi=false;
$value=@$_POST["value"];
if($value=='') $value=@$_GET["value"];
$categoryid=@$_POST["categoryid"];
if($categoryid=='') $categoryid=@$_GET["categoryid"];
if($categoryid=='') $categoryid='ALL';
$place=@$_POST["place"];
if($place=='') $place=@$_GET["place"];
if($place=='') $place='ALL';
/*if($value=='')
{
die('<div class="warning">Provide String to search. ');
}*/
/*$query="SELECT item.id
FROM `item` INNER JOIN `ccinfo`
ON item.ccid=ccinfo.ccid
WHERE (
((item.name LIKE '%".$value."%' ) OR (item.description LIKE '%".$value."%' ))
AND ( ccinfo.address LIKE '%".$place."%' )
AND ( item.status != 'Sold' )
)";*/
//$query="select *from item where name='Bhaisi'";
// this->query=$query;
//echo"the passed query is:$query";
//$query="select item.id,item.name,item.price,item.status,item.picture,item.description,ccinfo.address from item,ccinfo,category where item.name='%$value%'AND ccinfo.address='%$place%'AND item.ccid=ccinfo.ccid";
$querytemp = mysql_query($query);
$this->p["count"]= mysql_num_rows($querytemp);
$this->p["total_page"]=ceil($this->p["count"]/$this->p["baris"]);
if ($this->page<=1)
$this->page=1;
elseif ($this->page>$this->p["total_page"])
$this->page=$this->p["total_page"];
$this->p["mulai"]=$this->page*$this->p["baris"]-$this->p["baris"];
if($categoryid=="ALL")
{
//echo"inside query";
$query=$query." limit ".$this->p["mulai"].",".$this->p["baris"];
$query=mysql_query($query) or die("Query Error");
$this->query=$query;
}
else
{
$query=$query." limit ".$this->p["mulai"].",".$this->p["baris"];
$query=mysql_query($query) or die("Query Error");
$this->query=$query;
//echo"inside query1";
}
/*{
echo "<br>function>>database.php>>search";
$con=connectdb();
if($place=='ALL') {
$ccinfo_address='%';
echo 'place = all';
}
else{
$ccinfo_address=$place;
echo 'place != all';
}
if($categoryid=='ALL')
{
$sql="SELECT item.id
FROM `item` INNER JOIN `ccinfo`
ON item.ccid=ccinfo.ccid
WHERE (
((item.name LIKE '%".$value."%' ) OR (item.description LIKE '%".$value."%' ))
AND ( ccinfo.address LIKE '%".$ccinfo_address."%' )
AND ( item.status != 'Sold' )
)";
echo 'category = all';
}
else
{
echo "<br>jasdfksfhasdkfjkasd category != all";
$sql="SELECT item.id
FROM `item` INNER JOIN `ccinfo`
ON item.ccid=ccinfo.ccid
WHERE (
((item.name LIKE '%".$value."%' ) OR (item.description LIKE '%".$value."%' ))
AND ( item.categoryid='".$categoryid."' )
AND ( ccinfo.address LIKE '%".$ccinfo_address."%' )
AND ( item.status != 'Sold' )
)";
}
$result=mysql_query($sql,$con)
or //die($sql.' <div class="error"> ERROR gsdfgsdgwhile searching in database<br>'.mysql_error().'</div>');
die($sql." cannot be executed");
echo 'result = '.$result;
return $result;
}*/
}
function result()
{
echo"inside result function";
return $result=mysql_fetch_object($this->query);
}
function result_assoc()
{
//echo"inside result assoc";
//echo"$this->query";
return mysql_fetch_assoc($this->query);
}
function print_no()
{
$number=$this->p["mulai"]+=1;
return $number;
}
function print_color($color1,$color2)
{
if (empty($this->p["count_color"]))
$this->p["count_color"] = 0;
if ( $this->p["count_color"]++ % 2 == 0 ) {
return $color=$color1;
} else {
return $color=$color2;
}
}
function print_info()
{
$page=array();
$page["start"]=@$this->p["mulai"]+1;
$page["end"]=@$this->p["mulai"]+@$this->p["baris"];
$page["total"]=@$this->p["count"];
$page["total_pages"]=@$this->p["total_page"];
if ($page["end"] > $page["total"]) {
$page["end"]=@$page["total"];
}
if (empty($this->p["count"])) {
$page["start"]=0;
}
return $page;
}
function print_link()
{
//generate template
function number($i,$number)
{
return ereg_replace("^(.*)%%number%%(.*)$","\\1$i\\2",$number);
}
$print_link = false;
if (@$this->p["count"]>@$this->p["baris"]) {
// print prev
if ($this->page>1)
$print_link .= "<a href=\"".$_SERVER["PHP_SELF"]."?".$_SERVER["QUERY_STRING"]."&page=".($this->page-1)."\">".$this->prev."</a>\n";
// set number
$this->p["bawah"]=$this->page-$this->p["langkah"];
if ($this->p["bawah"]<1) $this->p["bawah"]=1;
$this->p["atas"]=$this->page+$this->p["langkah"];
if ($this->p["atas"]>$this->p["total_page"]) $this->p["atas"]=$this->p["total_page"];
// print start
if ($this->page<>1)
{
for ($i=$this->p["bawah"];$i<=$this->page-1;$i++)
$print_link .="<a href=\"".$_SERVER["PHP_SELF"]."?".$_SERVER["QUERY_STRING"]."&page=$i\">".number($i,$this->number)."</a>\n";
}
// print active
if ($this->p["total_page"]>1)
$print_link .= "<b>".number($this->page,$this->number)."</b>\n";
// print end
for ($i=$this->page+1;$i<=$this->p["atas"];$i++)
$print_link .= "<a href=\"".$_SERVER["PHP_SELF"]."?".$_SERVER["QUERY_STRING"]."&page=$i\">".number($i,$this->number)."</a>\n";
// print next
if ($this->page<$this->p["total_page"])
$print_link .= "<a href=\"".$_SERVER["PHP_SELF"]."?".$_SERVER["QUERY_STRING"]."&page=".($this->page+1)."\">".$this->next."</a>\n";
return $print_link;
}
}
}
?>
the code for search.php is as below:
search.php
<?
include("search_class.php");
include("./functions/database.php");
include("./forms/form_search1.php");
$paging=new paging(9,9);
$paging1=new paging(9,9);
session_start();
$value=@$_POST['value'];
$place=@$_POST['place'];
$category=@$_POST['categoryid'];
//To restart a new session when the new entry has been added to the fields for searching//
if((!(@$_POST['value']==""))||(!(@$_POST['place']==""))||(!(@$_POST['categoryid']=="")))
{
session_unregister('test');//unregistering the already registered session
session_unregister('place');
session_unregister('category');
}
if(!(isset($_SESSION['test'])))
{
$_SESSION['test']=@$value;
$_SESSION['place']=@$place;
$_SESSION['category']=@$category;
}
if(!(session_is_registered('test')))
{
session_register('test');
session_register('place');
session_register('category');
$test="test";
session_start(); //start session and initialize the variable if not already done!
$_SESSION['test']=@$value;//setting value of session instead of only value
$_SESSION['place']=@$place;
$_SESSION['category']=@$category;
//session_register($test);
//echo"session not set1";
//echo"$_SESSION[test]";
}
else
{
echo"Search for";
$t=$_SESSION['test'];
echo" $t<br>";
$s=$_SESSION['place'];
//echo"<br>Posted from: $s</br>";
$cat=$_SESSION['category'];
//echo"For the category:$cat<br>";
}
$paging->db("localhost","root","NepalWireLess","Haatbazar");
$paging->query("select item.id,item.name,item.price,item.description,item.status,item.picture,ccinfo.address from item,ccinfo where item.name like'%$t%' and item.ccid=ccinfo.ccid order by item.id desc");
$page=$paging->print_info();
echo "Data $page[start] - $page[end] of $page[total] [Total $page[total_pages] Pages]<hr>\n";
$imagedir='images/itemimages/';
echo "<table border=0 cellspacing=20>";
echo "<tr width=100% height=30>";
$count=1;
while ($result=$paging->result_assoc()) {
$ccid=@$result[ccid];
$paging1->query("select *from ccinfo where ccid='$ccid '");
$result1=$paging1->result_assoc();
echo "<td>";
$image=$result["picture"];
//echo"$imagedir";
echo "<table border=1 >";
echo "<tr><td valign=top width='100%' height=10 align=center class=display1><b>$result[name]</b></td></tr>";
echo "<tr><td valign=top height=200 align=center class=display1><img width=200 height=200 src='$imagedir/$image' alt=$result[description]></td></tr>";
echo "<tr><td align=center class=display2>ID:$result[id]</td></tr>";
echo "<tr><td align=center class=display2>Rs.$result[price]</td></tr>";
echo "<tr><td align=center class=display2>Status:$result[status]</td></tr>";
echo "<tr><td align=center class=display2>Location:$result[address]</td></tr>";
echo "</table>";
echo "</td>";
if(($count%3)==0){
echo "</tr></table><br>";
echo "<table border=0 cellspacing=20>";
echo "<tr width=100% height=30>";
//error_report('0');
}
$count++;
}
echo "</tr></table>";
echo "<hr>".$paging->print_link();
?>