0

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>
3
Contributors
2
Replies
3
Views
5 Years
Discussion Span
Last Post by qazplm114477
0

You're trying to include an image. I don't think you can do that.

0

either echo the url into an image tag or do a file_get_contents() on the image, send the correct headers to display an image and than echo it.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.