Forum Moderators: coopster
Parse error: syntax error, unexpected $end in /home/ncfinder/public_html/florida/display.php on line 163
Which line 163 is the very last line of my page. </html>
<?php
$search = @$_GET['search'];
mysql_connect("localhost","username","password");
mysql_select_db("dbname") or die("Unable to select database");
if($search)
{
if(!isset($_GET['page'])){
$page = 1;
} else {
$page = $_GET['page'];
}
// Define the number of results per page
$max_results = 25;
// Figure out the limit for the query based
// on the current page number.
$from = (($page * $max_results) - $max_results);
$query = "SELECT * FROM job_listings WHERE city LIKE '%$search%' and showad='y' ORDER by date DESC LIMIT $from, $max_results";
$result = mysql_query($query) or die(mysql_error());
mysql_close();
while ($row = mysql_fetch_array($result))
{
echo "
<table cellspacing=0 cellpadding=0>
<tr>
<td width=320 bgcolor=#dde8ec>
<div class=results>
<b><a href=http://www.websitename.com/florida/ad.php?ad=".$row["ad"].">".$row["job_title"]."</a></b>
</div>
</td>
<td width=5 bgcolor=#dde8ec></td>
<td width=200 bgcolor=#dde8ec>
<div class=results>
".$row["company_name"]."
</div>
</td>
<td width=100 bgcolor=#dde8ec>
<div class=results>
".$row["date"]."
</div>
</td>
</tr>
</table>
";}
// Figure out the total number of results in DB:
$total_results = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM job_listings WHERE city LIKE '%$search%'"),0);
// Figure out the total number of pages. Always round up using ceil()
$total_pages = ceil($total_results / $max_results);
echo "<center>$total_results Total results<br />";
// Build Previous Link
if($page > 1){
$prev = ($page - 1);
echo "<a href=\"".$_SERVER['php_SELF']."?page=$prev&search=$search\">Previous</a> ";
}
for($i = 1; $i <= $total_pages; $i++){
if(($page) == $i){
echo "[$i] ";
}
else {
echo "<a href=\"".$_SERVER['php_SELF']."?page=$i&search=$search\">$i</a> ";
}
}
// Build Next Link
if($page < $total_pages){
$next = ($page + 1);
echo "<a href=\"".$_SERVER['php_SELF']."?page=$next&search=$search\">Next</a>";
}
?>
Make the last lines:
echo "<a href=\"".$_SERVER['php_SELF']."?page=$next&search=$search\">Next</a>";
}
}// ends first {
?>
You need a good editor that allows for PHP higlighting
it will help you among many functions to figure
ends and beginnings of { } ( ) etc...
Warning: mysql_result(): supplied argument is not a valid MySQL result resource in /home/ncfinder/public_html/florida/display.php on line 103
and line 103 is
$total_results = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM job_listings WHERE city LIKE '%$search%'"),0);
mysql_close();
and everything now works just fine. So all my frustrations have been between that and me missing the } ... what a morning I tell you. Thank you for the welcome, Ive read the forums on and off for the past year or so, this time I had to ask for help. Thanks again for your assistance.