I am having an issue. I keep getting the following error: Parse error: syntax error, unexpected T_STRING in C:\xampp\htdocs\test\banners\banner1.jpg on line 1. What I am trying to do is dynamically not only change content, but change a banner in the header section of code to correspond with the content. My code is below:
<div id="header"><?php
$banner_dir = 'banners';
if (!empty($_GET['b'])){
$pages2 = scandir ($banner_dir, 0);
unset ($pages2[0], $pages2[1]);
$b = $_GET['b'];
if (in_array($b.'.jpg', $pages2)) {
include($banner_dir.'/'.$b.'.jpg');
} else {
echo 'Sorry, page not found.';
}
} else {
include($banner_dir.'/banner4.jpg');
}
?>
</div>
<div id="menu">
<a href="test_banner.php">Home</a>
<a href="test_banner.php?p=aboutus&b=banner1">About Us</a>
<a href="test_banner.php?p=contactus">Contact Us</a>
<a href="test_banner.php?p=news">News</a>
</div>
<div id="content">
<?php
$pages_dir = 'pages';
if (!empty($_GET['p'])){
$pages = scandir ($pages_dir, 0);
unset ($pages[0], $pages[1]);
$p = $_GET['p'];
if (in_array($p.'.inc.php', $pages)) {
include($pages_dir.'/'.$p.'.inc.php');
} else {
echo 'Sorry, page not found.';
}
} else {
include($pages_dir.'/home.inc.php');
}
?>
</div>