AJW Posted December 9, 2007 Share Posted December 9, 2007 I'm trying to do case/include statements for the navigation on my portfolio site, using a basic code I've implemented with the last couple of versions. However, time constraints forced me to use a free template for my site this time around, and I'm running into buckets of problems trying to get it to play nice with this bit of PHP code. <?php echo '<?xml version="1.0"?>'; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>ajwart.com-- the Art of Ashlee J. Williams</title> <!-- version 1.0 - released Nov 18, 2006 --> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <meta name="generator" content="Jonas John (www.jonasjohn.de)" /> <meta name="description" content="put a good description in here" /> <meta name="keywords" content="and, insert, some, good, keywords" /> <!-- default stylesheet --> <link rel="stylesheet" type="text/css" href="css/flowertree.css" media="screen, tv, projection" title="Default" /> <!-- print stylesheet (and print preview) --> <link rel="stylesheet" type="text/css" href="css/print.css" media="print" /> <link rel="alternative stylesheet" type="text/css" href="css/print.css" media="screen" title="Print Preview" /> <!-- Navigational metadata (an accessibility feature - use opera to preview) --> <link rel="top" href="index.html" title="Homepage" /> <link rel="up" href="index.html" title="Up" /> <link rel="first" href="index.html" title="First page" /> <link rel="previous" href="index.html" title="Previous page" /> <link rel="next" href="index.html" title="Next page" /> <link rel="last" href="index.html" title="Last page" /> <link rel="toc" href="index.html" title="Table of contents" /> <link rel="index" href="index.html" title="Site map" /> </meta> </head> <body> <div id="logo" class="page"> <a href="index.php" title="Return home">ajwart<span id="logo_black">.com</span></a> </div> <div id="contentbox" class="page"> <div id="padding"> <div id="innerpage"> <div id="content"> <?php if (!isset($_GET['page'])) else $page='home'; $page= $_GET['page'] ; switch($page) { case 'home': include "index.php"; break; case 'gallery': include ("gallery.php"); break; case 'animation': include ("animation.php"); break; case 'contact': include ("contact.php"); break; default: include "content.php"; break; } ?> </div> </div> </div> </div> <!-- i love clean source code --> <div id="menu" class="links"> <a href="content.php?page=home">home</a> / <a href="gallery.php?page=gallery">gallery</a> / <a href="index.html?page=animation">animation</a> / <a href="index.html?page=contact">contact</a> </div> </body> </html> Namely, when I try and open the page it's giving me XML errors about the php not being well formed on Line Number 52, Column 19: if (!isset($_GET['page'])) else $page='home'; $page= $_GET['page'] ; and the arrow is pointing to the p in (!isset($_GET['page'])). I'm very new to PHP; in fact, the only PHP code I've ever used has been this one case/include statement. I've been tearing my hair out for most of the morning trying to figure out what the heck I'm doing wrong, since this has worked all the other times I've used it. I'm wondering if it's because this template uses strict XHTML; usually, I use transitional. Any help with this would be much appreciated. Thanks in advance! Quote Link to comment Share on other sites More sharing options...
rab Posted December 9, 2007 Share Posted December 9, 2007 <?php if( !isset($_GET['page']) ) $_GET['page'] = 'home'; switch($_GET['page']) { case 'home': include "index.php"; break; case 'gallery': include ("gallery.php"); break; case 'animation': include ("animation.php"); break; case 'contact': include ("contact.php"); break; default: include "content.php"; break; } ?> Your syntax was incorrect. if(!isset($_GET['page'])) else $page='home'; PHP was expecting a code between the if/else statements Quote Link to comment Share on other sites More sharing options...
AJW Posted December 10, 2007 Author Share Posted December 10, 2007 I made the change, but I'm receiving the same error message. I pasted it below, for reference: XML Parsing Error: not well-formed Location: file:///C:/Program%20Files/Apache%20Software%20Foundation/Apache2.2/htdocs/flowertree/index.php Line Number 53, Column 19: if( !isset($_GET['page']) ) ------------------^ Quote Link to comment Share on other sites More sharing options...
rab Posted December 10, 2007 Share Posted December 10, 2007 Well, your accessing the PHP script as a file on the system. Try http://localhost/flowertree/index.php Quote Link to comment Share on other sites More sharing options...
AJW Posted December 10, 2007 Author Share Posted December 10, 2007 Wow. I feel...supremely stupid, at the moment. This whole time I thought I'd been viewing the page through localhost; I'm so used to using the "Preview in Browser" button in Dreamweaver, I didn't even remember that I had to go and type in the manual address. You have my eternal thanks. Excuse me while I go beat my head against a wall for the next ten minutes. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.