Jump to content

PHP Parse error: syntax error


jamesclues

Recommended Posts

getting following error message [30-Mar-2018 17:14:34 UTC] PHP Parse error: syntax error, unexpected end of file in /home/hotels/public_html/3.php on line 122 . Spent 2 hours trying to make this work anyone got any ideas maybe i am just tired and not seeing what the problem is i have made sure all my connections are closed off.

 
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Base Hotel - Standard Room</title>
<link rel="stylesheet" href="system/css/global.css">
<link class="colour" rel="stylesheet" href="system/css/colour-blue.css">
<link class="pattern" rel="stylesheet" href="system/css/pattern-china.css">
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css">
</head>
<?php
include 'header.php';
?>

<?php
include 'conn.php';

// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);

//Query
$sql = "SELECT * FROM Hotels WHERE hotelid = '1' LIMIT 1;";

$result = mysqli_query ($conn, $sql);

while($row = mysqli_fetch_array($result)) {

$string = $facilities;
$delimiters = Array(",");

$facilitiessplit = explode($delimiters,$string);

//Whatever you want to do for each row...
echo "
<div id='container'>
<header>
<div id='header'>
<div class='h1'>
<h1><span> ".$row[hotelname]." </span>
<span class='tagline'> ".$row[address]." </span></h1>
</div>
</div>

</header>
<!-- Header | END -->
<!-- Content | START -->
<main>
<div class='centre'>
<div id='left'>
<!-- Slideshow | START -->
<div id='slideshow'>
<div class='slider'>
<div class='item'><img alt='' src='".$row[hotelimg1]."' width='770' height='500' /></div>
<div class='item'><img alt='' src='".$row[hotelimg2]."' width='770' height='500' /></div>
<div class='item'><img alt='' src='".$row[hotelimg3]."' width='770' height='500' /></div>
<div class='item'><img alt='' src='".$row[hotelimg4]."' width='770' height='500' /></div>
<div class='item'><img alt='' src='".$row[hotelimg5]."' width='770' height='500' /></div>
</div>
<div class='nav'>
<a class='prev'><i class='fa fa-chevron-left'></i></a>
<a class='next'><i class='fa fa-chevron-right'></i></a>
</div>
</div>
<!-- Slideshow | END -->
<div id='content'>
<div align='left'>
<h2><strong>Welcome to </strong> ".$row[hotelname]."</h2>
<p>
".$row[hoteldescrtiption]."
</p>
<ul class='tags'>
echo '<li>';
print_r($facilitiessplit);
echo '</li>';
</ul>
</div>
<a href='guest-book.html' class='button'><span data-hover='BOOK ONLINE'>BOOK ONLINE</span></a>
</div>
</div>
}

$conn->close();
?>
<!-- Sidebar | START -->
<?php
include 'sidebar.php';
?>
<!-- Sidebar | END -->
</div>
<!-- Google Map | START -->
<script>
function initialize() {
var latlng = new google.maps.LatLng(-31.957482,115.856868);
var myOptions = {
zoom: 14,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP,
scrollwheel: false
};
var map = new google.maps.Map(document.getElementById('googlemap'), myOptions);
var marker = new google.maps.Marker({
position: latlng,
map: map,
icon: 'system/images/point.png'
});
}
function loadScript() {
var script = document.createElement('script');
script.type = 'text/javascript';

script.src = 'https://maps.googleapis.com/maps/api/js&callback=initialize';
document.body.appendChild(script);
}
window.onload = loadScript;
</script>
<div id='map'>
<div id='googlemap'></div>
</div>
<!-- Google Map | END -->
</main>

<?php
include 'footer.php';
?>

 

Link to comment
Share on other sites

Barand's right about the quotes - looks like you're missing a closing quote from your HTML block. This is also a good reason not to output HTML via php - use a template language like Twig and this wouldn't be a problem (or at least would be easier to identify as there wouldn't be that huge chunk of HTML output in the middle of your script). Not only that, it would add the escaping your current script doesn't do.

 

As a side note just in case the formatting isn't a copy/paste issue - proper and consistent indentation makes scripts a lot easier to debug.

Link to comment
Share on other sites

If you build html in strings, I usually first deference all variables.  That way you don't have to append and the structure

is plain and regular.

 

$var_guys_name = $row->guysname;

 

or

 

$var_guys_name = $row['guysname'];

 

$html_out = "My name is $var_guys_name, and I love to fish";

 

It probably slows things down, but I'm only interested, most of the time, with supporting code.  Code switching, php on and off,

is hard for me to handle. I've never heard of twig... but I'll take a peek.  Sounds interesting.  Anything to make code readable.

Link to comment
Share on other sites

You're right!  Between my editor highlighting and a once upon a time error I always thought you had to.  Then again this could have been a perl leak.  Thank you.  This is an impact.  There will be code before and after this post.   lol

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.