Reputation: 145
I'm new to this coding game, but I cannot find my syntax/parse error in this code. The error is saying Line 86 which is the end of the code. I have tried to add brackets, but have not had luck. This is likely a basic question, but I have been struggling with it for awhile so thought I'd shoot it up here to see if I could get some clear guidance and stop just throwing stuff in.
<html>
<head>
<title>View Guestbook</title>
<link rel="stylesheet" type="text/css" href="css/king.css" />
</head>
<body>
<img src="images/KingLogo.jpg"><br>
<?php
include "king_common_functions.php";
viewGuestbook();
//****************************************************************
//Display Admin Guestbook Data (All Submissions)
//****************************************************************
function viewGuestbook()
{
$outputDisplay = "";
$myrowcount = 0;
$statement = "SELECT lastname, firstname, contact_type, contact_info,";
$statement = "city, comments, date_added";
$statement .= "FROM u1585_Guestbook ";
$statement .= "ORDER BY lastname ";
$sqlResults = selectResults($statement);
$error_or_rows = $sqlResults[0];
if (substr($error_or_rows, 0 , 5) == 'ERROR')
{
print "<br />Error on DB";
print $error_or_rows;
} else {
$arraySize = $error_or_rows;
for ($i=1; $i <= $error_or_rows; $i++)
{
$lastname = $sqlResults[$i]['lastname'];
$firstname = $sqlResults[$i]['firstname'];
$contact_type = $sqlResults[$i]['contact_type'];
$contact_info = $sqlResults[$i]['contact_info'];
$city = $sqlResults[$i]['city'];
$comments = $sqlResults[$i]['comments'];
$date_added = $sqlResults[$i]['date_added'];
$outputDisplay = "<h3>View Guestbook:</h3>";
$outputDisplay .= '<table border=1 style="color: black;">';
$outputDisplay .= '<tr><th>Last Name</th><th>First Name</th><th>Contact Type</th><th>Contact Info</th>';
$outputDisplay .= '<th>City</th><th>Comments</th><th>Date Added</th></tr>';
$numresults = mysql_num_rows($sqlResults);
for ($j = 0; $j < $numresults; $j++)
{
if (!($j % 2) == 0)
{
$outputDisplay .= "<tr style=\"background-color: #F5DEB3;\">";
} else {
$outputDisplay .= "<tr style=\"background-color: white;\">";
}
$myrowcount++;
$outputDisplay .= "<td>".$lastname."</td>";
$outputDisplay .= "<td>".$firstname."</td>";
$outputDisplay .= "<td>".$contact_type."</td>";
$outputDisplay .= "<td>".$contact_info."</td>";
$outputDisplay .= "<td>".$city."</td>";
$outputDisplay .= "<td>".$comments."</td>";
$outputDisplay .= "<td>".$date_added."</td>";
$outputDisplay .= "</tr>";
}
}
$outputDisplay .= "</table>";
$outputDisplay .= "<br /><br /><b>Number of Rows in Results: $myrowcount </b> <br /><br />";
print $outputDisplay;
}
?>
</p>
</body>
</html>
Upvotes: 0
Views: 155
Reputation: 10732
Your for
loop here isn't being closed properly, I think:
for ($j = 0; $j < $numresults; $j++)
{
if (!($j % 2) == 0)
{
$outputDisplay .= "<tr style=\"background-color: #F5DEB3;\">";
} else {
$outputDisplay .= "<tr style=\"background-color: white;\">";
}
$myrowcount++;
Indenting your code makes it much easier to spot where you're missing braces.
Upvotes: 3
Reputation: 219874
Your function is missing its closing bracket. A decent IDE or text editor would spot this quickly for you.
Upvotes: 1