It is due to your <?php endwhile; ?>, which closes ?> before closing the function's }, without re-opeining <?php. Since there is no subsequent code inside <?php ?>, the PHP parser sees the remaining stuff outside as plain text output and assumes you have no properly closed the }. It happens that that is the end of the file, and so that is how the error is reported.
while ($restaurant = mysql_fetch_array($restresult)) :
// Trim article for preview
$preview = trim_str($restaurant['fullarticle'], 270);
?>
<li>
<img alt="<?=fixup($restaurant['heading'])?>" src="images/frontpage/<?=$restaurant['bigimage']?>" width="615" height="309" />
<a href="#" class="read-more">Read More</a>
<p>
<strong><a href="#"><?=fixup($restaurant['heading'])?></a></strong>
<em><?=fixup($preview)?></em>
</p>
</li>
<?php
endwhile; // Don't close ?> here!
The while: / endwhile syntax is useful for templating where you are primarily mixing HTML with PHP code, but can be confusing when used inside a function like this, as you lose the visual cues provided by open and closed {} groups. I kind of recommend against mixing the syntax in this way.
Really, I would recommend against ever closing and reopening <?php ?> inside a function, but that is a matter of style. Instead, construct the strings that a function outputs and echo or return them.
function ouputMainSlider() {
global $USER;
// Get details
$query = "SELECT id, bigimage, heading, fullarticle, dateadded FROM news WHERE status = 1 ";
$query .= "AND (state = '" . $USER->state . "' OR state = 'ALL') AND newstype != 1 and bigimage != '' ";
$query .= "ORDER BY dateadded DESC LIMIT 10";
$restresult = mysql_query($query);
$html = "";
while ($restaurant = mysql_fetch_array($restresult)) {
// Trim article for preview
// You can't call functions in the HEREDOC, so call them here first
$preview = fixup(trim_str($restaurant['fullarticle'], 270));
$heading = fixup($restaurant['heading']);
// Build the string with a HEREDOC, insead of directly sending it to the output buffer
// by closing ?> and reopening <?php
$html .=<<<HTMLSTRING
<li>
<img alt="$heading" src="images/frontpage/{$restaurant['bigimage']}" width="615" height="309" />
<a href="#" class="read-more">Read More</a>
<p>
<strong><a href="#">$heading</a></strong>
<em>$preview</em>
</p>
</li>
HTMLSTRING;
// No whitespace before the closing of the HEREDOC!
}
// Then echo the HTML output
echo $html;
}
?>tags but I see it's been answered.