mrk112 Posted March 3, 2006 Share Posted March 3, 2006 Could anyone tell me why this code doesn't want to work?[code]<?phpif (empty($_GET['page'])) { $page = "1";}$data = file_get_contents("info.dat");$exploded = explode(";", $data);for ($i=0; sizeof($exploded) > $i && $found != true; $i++) { if (strcmp($page, $exploded[$i]) == 0 && is_file("exploded[$i+1]")) { $found = true; $filename = "exploded[$i+1]"; $style = "exploded[$i+2]"; $title = "exploded[$i+3]"; } else { $filename = "404.txt"; $style = "style1.css"; $title = "Error 404: Page not found"; }}?><!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" lang="en-GB" xml:lang="en-GB"><head> <meta http-equiv="Content-type" content="text/html; charset=iso-8859-1" /> <title><?php echo "$title" ?></title> <link rel="stylesheet" href="<?php echo "$style" ?>" type="text/css" /></head><body> <div id="header"> <h1>u02mah5's site...</h1> <h2>dedicated to all things open source</h2> </div> <div id="navigation"> <ul> <li><a href="">Home Page</a></li> <li><a href="">Applications</a></li> <li><a href="">Formats</a></li> <li><a href="">Linux</a></li> </ul> </div> <div id="content"> <?php include "$filename" ?> </div></body></html>[/code]Here's the info.dat file:[code]1;home.txt;style1.css;Home Page;2;applications.txt;style1.css;Applications;3;formats.txt;style1.css;Formats;4;linux.txt;style1.css;Linux;[/code] Quote Link to comment https://forums.phpfreaks.com/topic/4032-help-with-simple-php-file/ Share on other sites More sharing options...
kanikilu Posted March 3, 2006 Share Posted March 3, 2006 [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]this code doesn't want to work[/quote] Please try to be a little more specific. Quote Link to comment https://forums.phpfreaks.com/topic/4032-help-with-simple-php-file/#findComment-13999 Share on other sites More sharing options...
mrk112 Posted March 3, 2006 Author Share Posted March 3, 2006 Sorry, I'll try and be more specific..The part where it seems to be falling over is in the second condition of the if statement but I don't know what the problem is.. I took it out and the file worked fine but after putting it back in I get the 404 page for everything..Also, I've been thinking about implementation overall.. Currently, the site uses addresses like index.php?page=1 etc which is fine so far.. The php file checks to see if it's listed as a valid page in my info.dat and also checks if the include file exists.. If all that is ok then it will load the appropriate page.. But then when I'm doing links I manually hard code them in (like the link I just mentioned). If I want to add pages then I'd have to edit the info.dat file and then manually edit the navigation etc.. Can anyone think of a better way of organizing the site? Bearing in mind that I'm going to have main pages (which I want menu entries on all pages) and sub pages..Thanks.. Quote Link to comment https://forums.phpfreaks.com/topic/4032-help-with-simple-php-file/#findComment-14010 Share on other sites More sharing options...
michaellunsford Posted March 4, 2006 Share Posted March 4, 2006 Tried putting the $ in front of your variable name -- or is that a variable name? "exploded[$i+1]"if (strcmp($page, $exploded[$i]) == 0 && is_file("exploded[$i+1]")) { Quote Link to comment https://forums.phpfreaks.com/topic/4032-help-with-simple-php-file/#findComment-14062 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.