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>

Recommended Answers

All 2 Replies

Member Avatar for diafol

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

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.