search not workin on my site when logged in??

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jarv
Forum Newbie
Posts: 13
Joined: Thu Jun 26, 2008 10:02 am

search not workin on my site when logged in??

Post by jarv »

on my site: http://www.retroandvintage.co.uk whne you login ast test/test teh search does not work?!

search page code

Code: Select all

<?php
session_start();
include_once("config.php");
$ebits = ini_get('error_reporting');
error_reporting($ebits ^ E_NOTICE);
// Check user logged in already:
checkLoggedIn("yes");

?>
<!doctype html>
<html>
<head>
<title>Pubs and bars in <? echo $Townsearch;?></title>
<meta name="description" content="Pubs, bars and restuarants in <? echo $Townsearch;?>" />
<meta name="keywords" content="<? echo $Townsearch;?>, pubs, bars, food, drink, nightlife" />
<meta name="Content-Language" content="en-gb" />
<meta name="robots" content="FOLLOW,INDEX" />
<meta name="revisit-after" content="2 days" />
<meta name="copyright" content="jbiddulph.com" />
<meta name="author" content="John Biddulph - Professional web site design and development in the south of england mainly worthing and brighton" />
<meta name="distribution" content="Global" />
<meta name="resource-type" content="document" />
<link rel="stylesheet" type="text/css" href="css/reset.css" />
<link rel="stylesheet" type="text/css" href="css/style.css" title="default" />
<link rel="alternate stylesheet" type="text/css" href="css/style1.css" title="1" />
<link rel="alternate stylesheet" type="text/css" href="css/style2.css" title="2" />
<script type="text/javascript" src="js/stylechanger.js"></script>
<script type="text/javascript" src="js/jquery-1.2.1.pack.js"></script>
<script type="text/javascript">
	function lookup(inputString) {
		if(inputString.length == 0) {
			// Hide the suggestion box.
			$('#suggestions').hide();
		} else {
			$.post("rpc.php", {queryString: ""+inputString+""}, function(data){
				if(data.length >0) {
					$('#suggestions').show();
					$('#autoSuggestionsList').html(data);
				}
			});
		}
	} // lookup
	
	function fill(thisValue) {
		$('#inputString').val(thisValue);
		setTimeout("$('#suggestions').hide();", 200);
	}
</script>
</head>
<body>
<?php if($messages) { displayErrors($messages); }?>
<header>
	<div id="title">
		<h1>My Pub Space
		 <a href="#" onClick="setActiveStyleSheet('default'); return false;"><img src="images/0.gif" width="15" height="15" border="0" alt="css style" /></a>&nbsp;<a href="#" onClick="setActiveStyleSheet('1'); return false;"><img src="images/1.gif" width="15" height="15" border="0" alt="css style" /></a>&nbsp;<a href="#" onClick="setActiveStyleSheet('2'); return false;"><img src="images/2.gif" width="15" height="15" border="0" alt="css style" /></a>
		 <span>
			 <form method="post" class="textbox" action="search.php?rsTown=<? echo $Town ?>&rsCounty=<? echo $County ?>">
					Town/City:&nbsp;<input type="text" size="26" class="searchbox" value="" name="rsTown" id="inputString" onKeyUp="lookup(this.value);" onBlur="fill();" />
				<input type="hidden" value="<? echo $County ?>" name="rsCounty" id="inputString" onKeyUp="lookup(this.value);" onBlur="fill();" />
				<div class="suggestionsBox" id="suggestions" style="display: none;">
					<img src="images/upArrow.png" style="position: relative; top: -36px; left: 105px; z-index:1;" alt="upArrow" />
					<div class="suggestionList" id="autoSuggestionsList">
&nbsp;					</div>
				</div>
				<input type="image" src="images/go.png" height="30" with="30" value="GO" />
			</form>
		</span>		</h1>
	</div>
</header>
<nav>
	<ul>
		<li class="selected"><a href="#">Home</a></li>
		<li><a href="#">Pubs</a></li>
		<li><a href="#">Members</a></li>
		<li><a href="#">Events</a></li>
		<li><a href="#">Register</a></li>
	</ul>
</nav>
<section id="intro">
	<header>
		<h2>Your social guide to going down the pub, online!</h2>
	</header>
	<p>Stuck in town with nowhere to go? Not sure if up the road or down the street is best? Need to be somewhere warm, cosy and friendly. Need a drink?....<br />You've come to the right place, mypubspace has it all!</p>
	<img src="images/pub.jpg" alt="pub" /> </section>
<div id="content">
	<div id="mainContent">
		<section>
			<article class="blogPost">
				<header>
					<h2>Pubs in <? echo $Town;?>, <? $_SESSION['county'];?></h2>
					<p>Posted on
						<time datetime="2009-06-29T23:31+01:00">June 29th 2009</time>
						by <a href="#">Mads Kjaer</a> - <a href="#comments">3 comments</a></p>
				</header>
				<?php

	$tableName="pubs";		
	$targetpage = "search.php"; 	
	$limit = 20; 
	
	$query = "SELECT COUNT(*) as num FROM $tableName WHERE rsTown LIKE '$Town%'";
	$total_pages = mysql_fetch_array(mysql_query($query));
	$total_pages = $total_pages['num'];
	
	$stages = 3;
	$page = $_GET['page'];
	if($page){
		$start = ($page - 1) * $limit; 
	}else{
		$start = 0;	
		}	
	
    // Get page data
	$query1 = "SELECT * FROM $tableName WHERE rsTown LIKE '$Town%' LIMIT $start, $limit";
	$result = mysql_query($query1);
	
	// Initial page num setup
	if ($page == 0){$page = 1;}
	$prev = $page - 1;	
	$next = $page + 1;							
	$lastpage = ceil($total_pages/$limit);		
	$LastPagem1 = $lastpage - 1;					
	
	
	$paginate = '';
	if($lastpage > 1)
	{	
	

	
	
		$paginate .= "<div class='paginate'>";
		// Previous
		if ($page > 1){
			$paginate.= "<a href='$targetpage?page=$prev&rsTown=$Town'>previous</a>";
		}else{
			$paginate.= "<span class='disabled'>previous</span>";	}
			

		
		// Pages	
		if ($lastpage < 7 + ($stages * 2))	// Not enough pages to breaking it up
		{	
			for ($counter = 1; $counter <= $lastpage; $counter++)
			{
				if ($counter == $page){
					$paginate.= "<span class='current'>$counter</span>";
				}else{
					$paginate.= "<a href='$targetpage?page=$counter&rsTown=$Town&rsCounty=$County'>$counter</a>";}					
			}
		}
		elseif($lastpage > 5 + ($stages * 2))	// Enough pages to hide a few?
		{
			// Beginning only hide later pages
			if($page < 1 + ($stages * 2))		
			{
				for ($counter = 1; $counter < 4 + ($stages * 2); $counter++)
				{
					if ($counter == $page){
						$paginate.= "<span class='current'>$counter</span>";
					}else{
						$paginate.= "<a href='$targetpage?page=$counter&rsTown=$Town&rsCounty=$County'>$counter</a>";}					
				}
				$paginate.= "...";
				$paginate.= "<a href='$targetpage?page=$LastPagem1&rsTown=$Town&rsCounty=$County'>$LastPagem1</a>";
				$paginate.= "<a href='$targetpage?page=$lastpage&rsTown=$Town&rsCounty=$County'>$lastpage</a>";		
			}
			// Middle hide some front and some back
			elseif($lastpage - ($stages * 2) > $page && $page > ($stages * 2))
			{
				$paginate.= "<a href='$targetpage?page=1&rsTown=$Town&rsCounty=$County'>1</a>";
				$paginate.= "<a href='$targetpage?page=2&rsTown=$Town&rsCounty=$County'>2</a>";
				$paginate.= "...";
				for ($counter = $page - $stages; $counter <= $page + $stages; $counter++)
				{
					if ($counter == $page){
						$paginate.= "<span class='current'>$counter</span>";
					}else{
						$paginate.= "<a href='$targetpage?page=$counter&rsTown=$Town&rsCounty=$County'>$counter</a>";}					
				}
				$paginate.= "...";
				$paginate.= "<a href='$targetpage?page=$LastPagem1&rsTown=$Town&rsCounty=$County'>$LastPagem1</a>";
				$paginate.= "<a href='$targetpage?page=$lastpage&rsTown=$Town&rsCounty=$County'>$lastpage</a>";		
			}
			// End only hide early pages
			else
			{
				$paginate.= "<a href='$targetpage?page=1&rsCounty=$County'>1</a>";
				$paginate.= "<a href='$targetpage?page=2&rsCounty=$County'>2</a>";
				$paginate.= "...";
				for ($counter = $lastpage - (2 + ($stages * 2)); $counter <= $lastpage; $counter++)
				{
					if ($counter == $page){
						$paginate.= "<span class='current'>$counter</span>";
					}else{
						$paginate.= "<a href='$targetpage?page=$counter&rsTown=$Town&rsCounty=$County'>$counter</a>";}					
				}
			}
		}
					
				// Next
		if ($page < $counter - 1){ 
			$paginate.= "<a href='$targetpage?page=$next&rsTown=$Town&rsCounty=$County'>next</a>";
		}else{
			$paginate.= "<span class='disabled'>next</span>";
			}
			
		$paginate.= "</div>";		
	
	
}
 echo $total_pages.' Results';
 // pagination
 echo $paginate;
?>

<ul>

<?php 
 

		while($row = mysql_fetch_array($result))
		{
		
		echo '<li>'.$row['rsPubName'].', '.$row['rsTown'].', '.$row['rsCounty'].'</li>';
		
		}
	$_SESSION['county'] = $row['rsCounty'];
	?>
</ul>
			</article>
		</section>
		<section id="comments">
			<h3>Comments</h3>
			<article>
				<header> <a href="#">George Washington</a> on
					<time datetime="2009-06-29T23:35:20+01:00">June 29th 2009 at 23:35</time>
				</header>
				<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut.</p>
			</article>
			<article>
				<header> <a href="#">Benjamin Franklin</a> on
					<time datetime="2009-06-29T23:40:09+01:00">June 29th 2009 at 23:40</time>
				</header>
				<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut.</p>
			</article>
			<article>
				<header> <a href="#">Barack Obama</a> on
					<time datetime="2009-06-29T23:59:00+01:00">June 29th 2009 at 23:59</time>
				</header>
				<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut.</p>
			</article>
		</section>
		<form action="" method="POST" method="post">
			<h3>Post a comment</h3>
			<p>
				<label for="name">Name</label>
				<input name="name" id="name" type="text" required />
			</p>
			<p>
				<label for="email">E-mail</label>
				<input name="email" id="email" type="email" required />
			</p>
			<p>
				<label for="website">Website</label>
				<input name="website" id="website" type="url" />
			</p>
			<p>
				<label for="comment">Comment</label>
				<textarea name="comment" id="comment" required></textarea>
			</p>
			<p>
				<input type="submit" value="Post comment" />
			</p>
		</form>
	</div>
	<aside>
		<section>
			<header>
				<h3>Members Login Area</h3>
			</header>
			<h4>Welcome <? print($_SESSION["rsUser"]); ?></h4>
			<ul>
				<li><a href="#">Sign up</a></li>
				<li><a href="#">Forgot Password</a></li>
			</ul>
		</section>
		<section>
			<header>
				<h3>Archives</h3>
			</header>
			<ul>
				<li><a href="#">December 2008</a></li>
				<li><a href="#">January 2009</a></li>
				<li><a href="#">February 2009</a></li>
				<li><a href="#">March 2009</a></li>
				<li><a href="#">April 2009</a></li>
				<li><a href="#">May 2009</a></li>
				<li><a href="#">June 2009</a></li>
			</ul>
		</section>
	</aside>
</div>
<footer>
	<div>
		<section id="about">
			<header>
				<h3>About</h3>
			</header>
			<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco <a href="#">laboris nisi ut aliquip</a> ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
		</section>
		<section id="blogroll">
			<header>
				<h3>Blogroll</h3>
			</header>
			<ul>
				<li><a href="#">NETTUTS+</a></li>
				<li><a href="#">FreelanceSwitch</a></li>
				<li><a href="#">In The Woods</a></li>
				<li><a href="#">Netsetter</a></li>
				<li><a href="#">PSDTUTS+</a></li>
			</ul>
		</section>
		<section id="popular">
			<header>
				<h3>Popular</h3>
			</header>
			<ul>
				<li><a href="#">This is the title of a blog post</a></li>
				<li><a href="#">Lorem ipsum dolor sit amet</a></li>
				<li><a href="#">Consectetur adipisicing elit, sed do eiusmod</a></li>
				<li><a href="#">Duis aute irure dolor</a></li>
				<li><a href="#">Excepteur sint occaecat cupidatat</a></li>
				<li><a href="#">Reprehenderit in voluptate velit</a></li>
				<li><a href="#">Officia deserunt mollit anim id est laborum</a></li>
				<li><a href="#">Lorem ipsum dolor sit amet</a></li>
			</ul>
		</section>
	</div>
</footer>
</body>
</html>
jarv
Forum Newbie
Posts: 13
Joined: Thu Jun 26, 2008 10:02 am

Re: search not workin on my site when logged in??

Post by jarv »

can anyone please help me here?
klevis miho
Forum Contributor
Posts: 413
Joined: Wed Oct 29, 2008 2:59 pm
Location: Albania
Contact:

Re: search not workin on my site when logged in??

Post by klevis miho »

I see this error:
Notice: Undefined index: page in D:\retroandvintage.co.uk\wwwroot\main.php on line 106

I think you should check a path.
jarv
Forum Newbie
Posts: 13
Joined: Thu Jun 26, 2008 10:02 am

Re: search not workin on my site when logged in??

Post by jarv »

yes, why does it say undefined index and still work? Can't I just have 1 search page based on weather someone is logged in or not?!
klevis miho
Forum Contributor
Posts: 413
Joined: Wed Oct 29, 2008 2:59 pm
Location: Albania
Contact:

Re: search not workin on my site when logged in??

Post by klevis miho »

What is at line 106?
jarv
Forum Newbie
Posts: 13
Joined: Thu Jun 26, 2008 10:02 am

Re: search not workin on my site when logged in??

Post by jarv »

main.php

Code: Select all

Login at: [url]http://www.retroandvintage.co.uk[/url] using: test/test
<?php
include_once("config.php");
include_once("functions.php");
// Check user logged in already:
checkLoggedIn("yes");
$Townsearch = $_REQUEST['rsTown'];
list($Town, $County) = split('[,]', $Townsearch);
ltrim($County,1);
?>
<!doctype html>
<html>
<head>
<title>Pubs and bars in the UK</title>
<meta name="description" content="xxx" />
<meta name="keywords" content="xxx" />
<meta name="Content-Language" content="en-gb" />
<meta name="robots" content="FOLLOW,INDEX" />
<meta name="revisit-after" content="2 days" />
<meta name="copyright" content="jbiddulph.com" />
<meta name="author" content="John Biddulph - Professional web site design and development in the south of england mainly worthing and brighton" />
<meta name="distribution" content="Global" />
<meta name="resource-type" content="document" />
<link rel="stylesheet" type="text/css" href="css/reset.css" />
<link rel="stylesheet" type="text/css" href="css/style.css" title="default" />
<link rel="alternate stylesheet" type="text/css" href="css/style1.css" title="1" />
<link rel="alternate stylesheet" type="text/css" href="css/style2.css" title="2" />
<script type="text/javascript" src="js/stylechanger.js"></script>
<script type="text/javascript" src="js/jquery-1.2.1.pack.js"></script>
<script type="text/javascript">
	function lookup(inputString) {
		if(inputString.length == 0) {
			// Hide the suggestion box.
			$('#suggestions').hide();
		} else {
			$.post("rpc.php", {queryString: ""+inputString+""}, function(data){
				if(data.length >0) {
					$('#suggestions').show();
					$('#autoSuggestionsList').html(data);
				}
			});
		}
	} // lookup
	
	function fill(thisValue) {
		$('#inputString').val(thisValue);
		setTimeout("$('#suggestions').hide();", 200);
	}
</script>
</head>
<body>
<?php if($messages) { displayErrors($messages); }?>
<header>
	<div id="title">
		<h1>My Pub Space
		 <a href="#" onClick="setActiveStyleSheet('default'); return false;"><img src="images/0.gif" width="15" height="15" border="0" alt="css style" /></a>&nbsp;<a href="#" onClick="setActiveStyleSheet('1'); return false;"><img src="images/1.gif" width="15" height="15" border="0" alt="css style" /></a>&nbsp;<a href="#" onClick="setActiveStyleSheet('2'); return false;"><img src="images/2.gif" width="15" height="15" border="0" alt="css style" /></a>
		 <span>
			 <form method="post" class="textbox" action="search1.php?rsTown=<? echo $Town ?>&rsCounty=<? echo $County ?>">
					Town/City:&nbsp;<input type="text" size="26" class="searchbox" value="" name="rsTown" id="inputString" onKeyUp="lookup(this.value);" onBlur="fill();" />
				<input type="hidden" value="<? echo $County ?>" name="rsCounty" id="inputString" onKeyUp="lookup(this.value);" onBlur="fill();" />
				<div class="suggestionsBox" id="suggestions" style="display: none;">
					<img src="images/upArrow.png" style="position: relative; top: -36px; left: 105px; z-index:1;" alt="upArrow" />
					<div class="suggestionList" id="autoSuggestionsList">
&nbsp;					</div>
				</div>
				<input type="image" src="images/go.png" height="30" with="30" value="GO" />
			</form>
		</span>		</h1>
	</div>
</header>
<nav>
	<ul>
		<li class="selected"><a href="main.php">Home</a></li>
		<li><a href="#">Pubs</a></li>
		<li><a href="#">Members</a></li>
		<li><a href="#">Events</a></li>
		<li><a href="#">Register</a></li>
	</ul>
</nav>
<section id="intro">
	<header>
		<h2>Your social guide to going down the pub, online!</h2>
	</header>
	<p>Stuck in town with nowhere to go? Not sure if up the road or down the street is best? Need to be somewhere warm, cosy and friendly. Need a drink?....<br />You've come to the right place, mypubspace has it all!</p>
	<img src="images/pub.jpg" alt="pub" /> </section>
<div id="content">
	<div id="mainContent">
		<section>
			<article class="blogPost">
				<header>
					<h2>This is the title of a blog post</h2>
					<p>Posted on
						<time datetime="2009-06-29T23:31+01:00">June 29th 2009</time>
						by <a href="#">Mads Kjaer</a> - <a href="#comments">3 comments</a></p>
				</header>
				<?php

	$tableName="pubs";		
	$targetpage = "main.php"; 	
	$limit = 20; 
	
	$query = "SELECT COUNT(*) as num FROM $tableName";
	$total_pages = mysql_fetch_array(mysql_query($query));
	$total_pages = $total_pages['num'];
	
	$stages = 3;
	$page = mysql_escape_string($_REQUEST['page']);
	if( isset($_REQUEST['page']) && ctype_digit($_REQUEST['page']) ) {
      $page = (int) $_GET['page'];
      $start = ($page - 1) * $limit;
}else{
      $start = 0;   
}
	
    // Get page data
	$query1 = "SELECT * FROM $tableName LIMIT $start, $limit";
	$result = mysql_query($query1);
	
	// Initial page num setup
	if ($page == 0){$page = 1;}
	$prev = $page - 1;	
	$next = $page + 1;							
	$lastpage = ceil($total_pages/$limit);		
	$LastPagem1 = $lastpage - 1;					
	
	
	$paginate = '';
	if($lastpage > 1)
	{	
	

	
	
		$paginate .= "<div class='paginate'>";
		// Previous
		if ($page > 1){
			$paginate.= "<a href='$targetpage?page=$prev'>previous</a>";
		}else{
			$paginate.= "<span class='disabled'>previous</span>";	}
			

		
		// Pages	
		if ($lastpage < 7 + ($stages * 2))	// Not enough pages to breaking it up
		{	
			for ($counter = 1; $counter <= $lastpage; $counter++)
			{
				if ($counter == $page){
					$paginate.= "<span class='current'>$counter</span>";
				}else{
					$paginate.= "<a href='$targetpage?page=$counter'>$counter</a>";}					
			}
		}
		elseif($lastpage > 5 + ($stages * 2))	// Enough pages to hide a few?
		{
			// Beginning only hide later pages
			if($page < 1 + ($stages * 2))		
			{
				for ($counter = 1; $counter < 4 + ($stages * 2); $counter++)
				{
					if ($counter == $page){
						$paginate.= "<span class='current'>$counter</span>";
					}else{
						$paginate.= "<a href='$targetpage?page=$counter'>$counter</a>";}					
				}
				$paginate.= "...";
				$paginate.= "<a href='$targetpage?page=$LastPagem1'>$LastPagem1</a>";
				$paginate.= "<a href='$targetpage?page=$lastpage'>$lastpage</a>";		
			}
			// Middle hide some front and some back
			elseif($lastpage - ($stages * 2) > $page && $page > ($stages * 2))
			{
				$paginate.= "<a href='$targetpage?page=1'>1</a>";
				$paginate.= "<a href='$targetpage?page=2'>2</a>";
				$paginate.= "...";
				for ($counter = $page - $stages; $counter <= $page + $stages; $counter++)
				{
					if ($counter == $page){
						$paginate.= "<span class='current'>$counter</span>";
					}else{
						$paginate.= "<a href='$targetpage?page=$counter'>$counter</a>";}					
				}
				$paginate.= "...";
				$paginate.= "<a href='$targetpage?page=$LastPagem1'>$LastPagem1</a>";
				$paginate.= "<a href='$targetpage?page=$lastpage'>$lastpage</a>";		
			}
			// End only hide early pages
			else
			{
				$paginate.= "<a href='$targetpage?page=1'>1</a>";
				$paginate.= "<a href='$targetpage?page=2'>2</a>";
				$paginate.= "...";
				for ($counter = $lastpage - (2 + ($stages * 2)); $counter <= $lastpage; $counter++)
				{
					if ($counter == $page){
						$paginate.= "<span class='current'>$counter</span>";
					}else{
						$paginate.= "<a href='$targetpage?page=$counter'>$counter</a>";}					
				}
			}
		}
					
				// Next
		if ($page < $counter - 1){ 
			$paginate.= "<a href='$targetpage?page=$next'>next</a>";
		}else{
			$paginate.= "<span class='disabled'>next</span>";
			}
			
		$paginate.= "</div>";		
	
	
}
 echo $total_pages.' Results';
 // pagination
 echo $paginate;
?>

<ul>

<?php 
 

		while($row = mysql_fetch_array($result))
		{
		
		echo '<li>'.$row['rsPubName'].', '.$row['rsTown'].', '.$row['rsCounty'].'</li>';
		if	($_SESSION["rsUser"] == "admin")
	{
		echo "<a href=\"edit.php?PUBID=".$row['PubID']."\" class=\"small\">edit this pub</a>";
	}
		
		}
	
	?>
</ul>
			</article>
		</section>
		<section id="comments">
			<h3>Comments</h3>
			<article>
				<header> <a href="#">George Washington</a> on
					<time datetime="2009-06-29T23:35:20+01:00">June 29th 2009 at 23:35</time>
				</header>
				<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut.</p>
			</article>
			<article>
				<header> <a href="#">Benjamin Franklin</a> on
					<time datetime="2009-06-29T23:40:09+01:00">June 29th 2009 at 23:40</time>
				</header>
				<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut.</p>
			</article>
			<article>
				<header> <a href="#">Barack Obama</a> on
					<time datetime="2009-06-29T23:59:00+01:00">June 29th 2009 at 23:59</time>
				</header>
				<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut.</p>
			</article>
		</section>
		<form action="#" method="POST" method="post">
			<h3>Post a comment</h3>
			<p>
				<label for="name">Name</label>
				<input name="name" id="name" type="text" required />
			</p>
			<p>
				<label for="email">E-mail</label>
				<input name="email" id="email" type="email" required />
			</p>
			<p>
				<label for="website">Website</label>
				<input name="website" id="website" type="url" />
			</p>
			<p>
				<label for="comment">Comment</label>
				<textarea name="comment" id="comment" required></textarea>
			</p>
			<p>
				<input type="submit" value="Post comment" />
			</p>
		</form>
	</div>
	<aside>
		<section>
			<header>
				<h3>Members Login Area</h3>
			</header>
			<h4>Welcome <? print($_SESSION["rsUser"]); ?></h4>
			<a href="logout.php">Logout</a>
		</section>
		<section>
			<header>
				<h3>Archives</h3>
			</header>
			<ul>
				<li><a href="#">December 2008</a></li>
				<li><a href="#">January 2009</a></li>
				<li><a href="#">February 2009</a></li>
				<li><a href="#">March 2009</a></li>
				<li><a href="#">April 2009</a></li>
				<li><a href="#">May 2009</a></li>
				<li><a href="#">June 2009</a></li>
			</ul>
		</section>
	</aside>
</div>
<footer>
	<div>
		<section id="about">
			<header>
				<h3>About</h3>
			</header>
			<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco <a href="#">laboris nisi ut aliquip</a> ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
		</section>
		<section id="blogroll">
			<header>
				<h3>Blogroll</h3>
			</header>
			<ul>
				<li><a href="#">NETTUTS+</a></li>
				<li><a href="#">FreelanceSwitch</a></li>
				<li><a href="#">In The Woods</a></li>
				<li><a href="#">Netsetter</a></li>
				<li><a href="#">PSDTUTS+</a></li>
			</ul>
		</section>
		<section id="popular">
			<header>
				<h3>Popular</h3>
			</header>
			<ul>
				<li><a href="#">This is the title of a blog post</a></li>
				<li><a href="#">Lorem ipsum dolor sit amet</a></li>
				<li><a href="#">Consectetur adipisicing elit, sed do eiusmod</a></li>
				<li><a href="#">Duis aute irure dolor</a></li>
				<li><a href="#">Excepteur sint occaecat cupidatat</a></li>
				<li><a href="#">Reprehenderit in voluptate velit</a></li>
				<li><a href="#">Officia deserunt mollit anim id est laborum</a></li>
				<li><a href="#">Lorem ipsum dolor sit amet</a></li>
			</ul>
		</section>
	</div>
</footer>
</body>
</html>
Search1.php

Code: Select all

<?php
session_start();
include_once("config.php");
$ebits = ini_get('error_reporting');
error_reporting($ebits ^ E_NOTICE);
// Check user logged in already:
checkLoggedIn("yes");
$Townsearch = $_REQUEST['rsTown'];
$County = $_REQUEST['rsCounty'];

// Delimiters may be slash, dot, or hyphen
list($Town, $County1) = split('[,]', $Townsearch);
$County1 = substr($County1, 1);

?>
<!doctype html>
<html>
<head>
<title>Pubs and bars in <? echo $Town;?>, <? echo $County1;?></title>
<meta name="description" content="Pubs, bars and restuarants in <? echo $Townsearch;?>" />
<meta name="keywords" content="<? echo $Townsearch;?>, pubs, bars, food, drink, nightlife" />
<meta name="Content-Language" content="en-gb" />
<meta name="robots" content="FOLLOW,INDEX" />
<meta name="revisit-after" content="2 days" />
<meta name="copyright" content="jbiddulph.com" />
<meta name="author" content="John Biddulph - Professional web site design and development in the south of england mainly worthing and brighton" />
<meta name="distribution" content="Global" />
<meta name="resource-type" content="document" />
<link rel="stylesheet" type="text/css" href="css/reset.css" />
<link rel="stylesheet" type="text/css" href="css/style.css" title="default" />
<link rel="alternate stylesheet" type="text/css" href="css/style1.css" title="1" />
<link rel="alternate stylesheet" type="text/css" href="css/style2.css" title="2" />
<script type="text/javascript" src="js/stylechanger.js"></script>
<script type="text/javascript" src="js/jquery-1.2.1.pack.js"></script>
<script type="text/javascript">
	function lookup(inputString) {
		if(inputString.length == 0) {
			// Hide the suggestion box.
			$('#suggestions').hide();
		} else {
			$.post("rpc.php", {queryString: ""+inputString+""}, function(data){
				if(data.length >0) {
					$('#suggestions').show();
					$('#autoSuggestionsList').html(data);
				}
			});
		}
	} // lookup
	
	function fill(thisValue) {
		$('#inputString').val(thisValue);
		setTimeout("$('#suggestions').hide();", 200);
	}
</script>
</head>
<body>
<?php if($messages) { displayErrors($messages); }?>
<header>
	<div id="title">
		<h1>My Pub Space
		 <a href="#" onClick="setActiveStyleSheet('default'); return false;"><img src="images/0.gif" width="15" height="15" border="0" alt="css style" /></a>&nbsp;<a href="#" onClick="setActiveStyleSheet('1'); return false;"><img src="images/1.gif" width="15" height="15" border="0" alt="css style" /></a>&nbsp;<a href="#" onClick="setActiveStyleSheet('2'); return false;"><img src="images/2.gif" width="15" height="15" border="0" alt="css style" /></a>
		 <span>
			 <form method="post" class="textbox" action="search1.php?rsTown=<? echo $Town; ?>&rsCounty=<? echo $County1; ?>">
					Town/City:&nbsp;<input type="text" size="26" class="searchbox" value="" name="rsTown" id="inputString" onKeyUp="lookup(this.value);" onBlur="fill();" />
				<div class="suggestionsBox" id="suggestions" style="display: none;">
					<img src="images/upArrow.png" style="position: relative; top: -36px; left: 105px; z-index:1;" alt="upArrow" />
					<div class="suggestionList" id="autoSuggestionsList">
&nbsp;					</div>
				</div>
				<input type="image" src="images/go.png" height="30" with="30" value="GO" />
			</form>
		</span>		</h1>
	</div>
</header>
<nav>
	<ul>
		<li class="selected"><a href="main.php">Home</a></li>
		<li><a href="#">Pubs</a></li>
		<li><a href="#">Members</a></li>
		<li><a href="#">Events</a></li>
		<li><a href="#">Register</a></li>
	</ul>
</nav>
<section id="intro">
	<header>
		<h2>Your social guide to going down the pub, online!</h2>
	</header>
	<p>Stuck in town with nowhere to go? Not sure if up the road or down the street is best? Need to be somewhere warm, cosy and friendly. Need a drink?....<br />You've come to the right place, mypubspace has it all!</p>
	<img src="images/pub.jpg" alt="pub" /> </section>
<div id="content">
	<div id="mainContent">
		<section>
			<article class="blogPost">
				<header>
					<h2>Pubs in <? echo $Town;?>, <? echo $County1;?></h2>
					<p>Posted on
						<time datetime="2009-06-29T23:31+01:00">June 29th 2009</time>
						by <a href="#">Mads Kjaer</a> - <a href="#comments">3 comments</a></p>
				</header>
				<?php

	$tableName="pubs";		
	$targetpage = "search1.php"; 	
	$limit = 20; 
	
	$query = "SELECT COUNT(*) as num FROM $tableName WHERE rsTown LIKE '$Town%'";
	$total_pages = mysql_fetch_array(mysql_query($query));
	$total_pages = $total_pages['num'];
	
	$stages = 3;
	$page = $_GET['page'];
	if($page){
		$start = ($page - 1) * $limit; 
	}else{
		$start = 0;	
		}	
	
    // Get page data
	$query1 = "SELECT * FROM $tableName WHERE rsTown LIKE '$Town%' LIMIT $start, $limit";
	$result = mysql_query($query1);
	echo $paginate['rsTown'];
	// Initial page num setup
	if ($page == 0){$page = 1;}
	$prev = $page - 1;	
	$next = $page + 1;							
	$lastpage = ceil($total_pages/$limit);		
	$LastPagem1 = $lastpage - 1;					
	
	
	$paginate = '';
	if($lastpage > 1)
	{	
	

	
		$paginate .= "<div class='paginate'>";
		// Previous
		if ($page > 1){
			$paginate.= "<a href='$targetpage?page=$prev&rsTown=$Town&rsCounty=$County1'>previous</a>";
		}else{
			$paginate.= "<span class='disabled'>previous</span>";	}
			

		
		// Pages	
		if ($lastpage < 7 + ($stages * 2))	// Not enough pages to breaking it up
		{	
			for ($counter = 1; $counter <= $lastpage; $counter++)
			{
				if ($counter == $page){
					$paginate.= "<span class='current'>$counter</span>";
				}else{
					$paginate.= "<a href='$targetpage?page=$counter&rsTown=$Town&rsCounty=$County1'>$counter</a>";}					
			}
		}
		elseif($lastpage > 5 + ($stages * 2))	// Enough pages to hide a few?
		{
			// Beginning only hide later pages
			if($page < 1 + ($stages * 2))		
			{
				for ($counter = 1; $counter < 4 + ($stages * 2); $counter++)
				{
					if ($counter == $page){
						$paginate.= "<span class='current'>$counter</span>";
					}else{
						$paginate.= "<a href='$targetpage?page=$counter&rsTown=$Town&rsCounty=$County1'>$counter</a>";}					
				}
				$paginate.= "...";
				$paginate.= "<a href='$targetpage?page=$LastPagem1&rsTown=$Town&rsCounty=$County1'>$LastPagem1</a>";
				$paginate.= "<a href='$targetpage?page=$lastpage&rsTown=$Town&rsCounty=$County1'>$lastpage</a>";		
			}
			// Middle hide some front and some back
			elseif($lastpage - ($stages * 2) > $page && $page > ($stages * 2))
			{
				$paginate.= "<a href='$targetpage?page=1&rsTown=$Town&rsCounty=$County1'>1</a>";
				$paginate.= "<a href='$targetpage?page=2&rsTown=$Town&rsCounty=$County1'>2</a>";
				$paginate.= "...";
				for ($counter = $page - $stages; $counter <= $page + $stages; $counter++)
				{
					if ($counter == $page){
						$paginate.= "<span class='current'>$counter</span>";
					}else{
						$paginate.= "<a href='$targetpage?page=$counter&rsTown=$Town&rsCounty=$County1'>$counter</a>";}					
				}
				$paginate.= "...";
				$paginate.= "<a href='$targetpage?page=$LastPagem1&rsTown=$Town&rsCounty=$County1'>$LastPagem1</a>";
				$paginate.= "<a href='$targetpage?page=$lastpage&rsTown=$Town&rsCounty=$County1'>$lastpage</a>";		
			}
			// End only hide early pages
			else
			{
				$paginate.= "<a href='$targetpage?page=1&rsCounty=$County1'>1</a>";
				$paginate.= "<a href='$targetpage?page=2&rsCounty=$County1'>2</a>";
				$paginate.= "...";
				for ($counter = $lastpage - (2 + ($stages * 2)); $counter <= $lastpage; $counter++)
				{
					if ($counter == $page){
						$paginate.= "<span class='current'>$counter</span>";
					}else{
						$paginate.= "<a href='$targetpage?page=$counter&rsTown=$Town&rsCounty=$County1'>$counter</a>";}					
				}
			}
		}
					
				// Next
		if ($page < $counter - 1){ 
			$paginate.= "<a href='$targetpage?page=$next&rsTown=$Town&rsCounty=$County1'>next</a>";
		}else{
			$paginate.= "<span class='disabled'>next</span>";
			}
			
		$paginate.= "</div>";		
	
	
}
 echo $total_pages.' Results';
 // pagination
 echo $paginate;
?>

<ul>

<?php 
 

		while($row = mysql_fetch_array($result))
		{
		
		echo '<li>'.$row['rsPubName'].', '.$row['rsTown'].', '.$row['rsCounty'].'</li>';
		if	($_SESSION["rsUser"] == "admin")
	{
		echo "<a href=\"edit.php?PUBID=".$row['PubID']."\" class=\"small\">edit this pub</a>";
	}
		}
	$_SESSION['county'] = $row['rsCounty'];
	?>
</ul>
			</article>
		</section>
		<section id="comments">
			<h3>Comments</h3>
			<article>
				<header> <a href="#">George Washington</a> on
					<time datetime="2009-06-29T23:35:20+01:00">June 29th 2009 at 23:35</time>
				</header>
				<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut.</p>
			</article>
			<article>
				<header> <a href="#">Benjamin Franklin</a> on
					<time datetime="2009-06-29T23:40:09+01:00">June 29th 2009 at 23:40</time>
				</header>
				<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut.</p>
			</article>
			<article>
				<header> <a href="#">Barack Obama</a> on
					<time datetime="2009-06-29T23:59:00+01:00">June 29th 2009 at 23:59</time>
				</header>
				<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut.</p>
			</article>
		</section>
		<form action="" method="POST" method="post">
			<h3>Post a comment</h3>
			<p>
				<label for="name">Name</label>
				<input name="name" id="name" type="text" required />
			</p>
			<p>
				<label for="email">E-mail</label>
				<input name="email" id="email" type="email" required />
			</p>
			<p>
				<label for="website">Website</label>
				<input name="website" id="website" type="url" />
			</p>
			<p>
				<label for="comment">Comment</label>
				<textarea name="comment" id="comment" required></textarea>
			</p>
			<p>
				<input type="submit" value="Post comment" />
			</p>
		</form>
	</div>
	<aside>
		<section>
			<header>
				<h3>Members Login Area</h3>
			</header>
			<h4>Welcome <? print($_SESSION["rsUser"]); ?></h4>
			<a href="logout.php">Logout</a>
			</ul>
		</section>
		<section>
			<header>
				<h3>Archives</h3>
			</header>
			<ul>
				<li><a href="#">December 2008</a></li>
				<li><a href="#">January 2009</a></li>
				<li><a href="#">February 2009</a></li>
				<li><a href="#">March 2009</a></li>
				<li><a href="#">April 2009</a></li>
				<li><a href="#">May 2009</a></li>
				<li><a href="#">June 2009</a></li>
			</ul>
		</section>
	</aside>
</div>
<footer>
	<div>
		<section id="about">
			<header>
				<h3>About</h3>
			</header>
			<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco <a href="#">laboris nisi ut aliquip</a> ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
		</section>
		<section id="blogroll">
			<header>
				<h3>Blogroll</h3>
			</header>
			<ul>
				<li><a href="#">NETTUTS+</a></li>
				<li><a href="#">FreelanceSwitch</a></li>
				<li><a href="#">In The Woods</a></li>
				<li><a href="#">Netsetter</a></li>
				<li><a href="#">PSDTUTS+</a></li>
			</ul>
		</section>
		<section id="popular">
			<header>
				<h3>Popular</h3>
			</header>
			<ul>
				<li><a href="#">This is the title of a blog post</a></li>
				<li><a href="#">Lorem ipsum dolor sit amet</a></li>
				<li><a href="#">Consectetur adipisicing elit, sed do eiusmod</a></li>
				<li><a href="#">Duis aute irure dolor</a></li>
				<li><a href="#">Excepteur sint occaecat cupidatat</a></li>
				<li><a href="#">Reprehenderit in voluptate velit</a></li>
				<li><a href="#">Officia deserunt mollit anim id est laborum</a></li>
				<li><a href="#">Lorem ipsum dolor sit amet</a></li>
			</ul>
		</section>
	</div>
</footer>
</body>
</html>
klevis miho
Forum Contributor
Posts: 413
Joined: Wed Oct 29, 2008 2:59 pm
Location: Albania
Contact:

Re: search not workin on my site when logged in??

Post by klevis miho »

Man come on, how are we suposed to find line 106 here? By counting the lines?
jarv
Forum Newbie
Posts: 13
Joined: Thu Jun 26, 2008 10:02 am

Re: search not workin on my site when logged in??

Post by jarv »

sorry, Line 106:

Code: Select all

$page = mysql_escape_string($_REQUEST['page']);
Post Reply