Whenever I run states.php, I get the following error:
Parse error: parse error, unexpected $ in /home/joel/public_html/portfolio/9/states.php on line 85
Line 85:
?>
As you can see, it doesn't make sense to have that type of error on the last line.
Here's lines 80-84:
echo get_footer($state);
}
echo "<br>";
include "states_footer.html";
Here is most of the source code:
states.php:
<?php
// get function list
include "functions.php";
// connect to db
db_connect() or die(mysql_error());
// rename state variable
$state = $_GET['state'];
include "states_header.html";
echo "<br>";
if(isset($_GET['state']))
{
include "ssi/list.php";
}else{
// Display header
echo get_header($state);
// List of cities in the state
$sql = "SELECT `city` FROM `{$tbl_prefix}shrimp_restaurants`, `{$tbl_prefix}shrimp_stores` WHERE `state` = '".$state."' LIMIT 1";
$query = mysql_query($sql) or die(mysql_error());
$row = mysql_fetch_array($query);
$num_rows = mysql_num_rows($query);
if($num_rows < 1)
{
echo "There are no shrimp restaurants or stores for $state. Please try another state.";
}else{
while($row = mysql_fetch_array($query))
{
$city = $row['city'];
// City Name ($city)
// Shrimp Restaurants
$sql = "SELECT * FROM `{$tbl_prefix}shrimp_restaurants` WHERE `city` = '".$city."' AND `show` = '1'";
$query = mysql_query($sql) or die(mysql_error());
$row = mysql_fetch_array($query);
$num_rows = mysql_num_rows($query);
if($num_rows < 1)
{
echo "There are no shrimp restaurants for $city, $state.";
}else{
while($row = mysql_fetch_array($query))
{
// Restaurant Details
$mapquest = generate_mapquest_link($row['address'],$city,$state,"USA",$row['zip']);
echo "<p><a href='$row[link]'>$row[name]</a> (<a href='$mapquest'>MapQuest</a>)<br>";
echo "<a href=javascript:popUp('details.php?type=restaurant&id=$row[id]')>Details</a>";
echo "</p>";
}
}
// Shrimp Stores
$sql = "SELECT * FROM `{$tbl_prefix}shrimp_stores` WHERE `city` = '".$city."' AND `show` = '1'";
$query = mysql_query($sql) or die(mysql_error());
$row = mysql_fetch_array($query);
$num_rows = mysql_num_rows($query);
if($num_rows < 1)
{
echo "There are no shrimp stores for $city, $state.";
}else{
while($row = mysql_fetch_array($query))
{
// Store Details
$mapquest = generate_mapquest_link($row['address'],$city,$state,"USA",$row['zip']);
echo "<p><a href='$row[link]'>$row[name]</a> (<a href='$mapquest'>MapQuest</a>)<br>";
echo "<a href=javascript:popUp('details.php?type=store&id={$row[id]}')>Details</a>";
echo "</p>";
}
}
}
// Display footer
echo "<br>";
echo get_footer($state);
}
echo "<br>";
include "states_footer.html";
?>
functions.php
<?php
include "mysql.php";
// connect to the mysql db
function db_connect()
{
global $database, $username, $password, $host, $tbl_prefix;
$connect_to_server = mysql_connect($host,$username,$password) or die(mysql_error());
mysql_select_db($database,$connect_to_server) or die(mysql_error());
return true;
}
// get the states header based on the states_id
function get_header($state)
{
global $tbl_prefix;
$sql = "SELECT * FROM `{$tbl_prefix}headers` WHERE `state` = '".$state."' LIMIT 1";
$query = mysql_query($sql) or die("FUNCTION HEADER: " . mysql_error());
while($row = mysql_fetch_array($query))
{
return $row[code=html];
}
}
// get the states footer based on the state_id
function get_footer($state)
{
global $tbl_prefix;
$sql = "SELECT * FROM `{$tbl_prefix}footers` WHERE `state` = '".$state."' LIMIT 1";
$query = mysql_query($sql) or die("FUNCTION FOOTER: " . mysql_error());
while($row = mysql_fetch_array($query))
{
return $row[code=html];
}
}
// determine whether the admin is logged in & take appopriate actions
function admin_page_header()
{
if(!session_is_registered("loggedin"))
{
echo "You are not logged in.";
echo "<br>Please <a href='index.php'>login</a>.";
exit;
}else{
echo "<p><a href='index.php?act=logout'>Logout</a></p>";
}
}
#
# Provide your users with dynamically generated links to MapQuest
# using basic address, city, state, or zipcode strings with this simple function.
#
function generate_mapquest_link($address,$city,$state,$country,$zip)
{
if ($country == "") $country="USA";
if ($address > "" && $city > "" && $state > "" && $zip > "")
{
$address = trim($address);
$address = str_replace(" ","+",$address);
$address = str_replace(",","%2C",$address);
$city = trim($city);
$city = str_replace(" ","+",$city);
$link="http://www.mapquest.com/maps/map.adp".
"?country=$country".
"&addtohistory=".
"&address=$address".
"&city=$city".
"&state=$state".
"&zip=$zip".
"&homesubmit=Get+Map";
}
else
$link = "*** Address Not Specified ***";
return $link;
}
?>
What's going wrong with this code? Is it on the client side or server side? Did I make a coding mistake? This is the first time I have ever seen this. Thanks for all your help in advance.