Jump to content

Parse Error with doctype


Tsalagi

Recommended Posts

I'm getting a parse error with this simple code. I don't get it. It worked one time then when I reloaded the page in FF the code throws this parse error.

Parse error: parse error in C:\wamp\www\bmreader.php on line 7

Line 7 is where the HTML Doctype line begins. Thanks in advance. Here is the code.

 

<?php

// This makes sure that the content is sent to the browser as text/html and the UTF-8 character set (since we didn't change it).
$feed->handle_content_type();


// Let's begin our XHTML webpage code.  The DOCTYPE is supposed to be the very first thing, so we'll keep it on the same line as the closing-PHP tag.>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>Sample SimplePie Page</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<style type="text/css">
body {
	font:12px/1.4em Verdana, sans-serif;
	color:#333;
	background-color:#fff;
	width:700px;
	margin:50px auto;
	padding:0;
}

a {
	color:#326EA1;
	text-decoration:underline;
	padding:0 1px;
}

a:hover {
	background-color:#333;
	color:#fff;

}

div.header {
	border-bottom:1px solid #999;
}

div.item {
	padding:5px 0;
	border-bottom:1px solid #999;
}
div.image {
height:250px;
width:250px;
border:3px solid blue;
}
</style>

</head>

<body>
<?php $feed = file_get_contents("http://www.nasa.gov/rss/image_of_the_day.rss");
$xml = new SimpleXmlElement($feed);?>
<?php foreach ($xml->channel->item as $entry){
  echo $entry->title;
  echo $entry->description;
}
endforeach;
?>


</body>
</html>

Link to comment
https://forums.phpfreaks.com/topic/179140-parse-error-with-doctype/
Share on other sites

add an ending php tag before the doctype declaration.

 

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

Thanks that got rid of one error but produced a parse error at the endforeach line. :facepalm:

I've scanned the code over and over and can't see any missing elements.

 

thanks for your time

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.