CK9 Posted March 19, 2009 Share Posted March 19, 2009 Hi there, I've been working on a new navigation system for my site using a method I found when I wanted the effect of frames without the little annoyances it gives. I've found, however, that it isn't working as well as I had hoped and am wondering how I should go about correcting the problems I'm facing. I'm still fairly new to PHP coding, and this is the first time I tried coding something without someone looking through the code before I put it into use. the code I'm using: <?php $pg = $_GET['pg']; if($_GET['pg'] == '') { $pg = "note"; } function pagechange($pg) { include("header.html"); echo "<table cols='2' border='0' cellpadding='10' cellspacing='0' align='center' width='100%'>"; echo "<tr>"; echo "<td width='16%'>"; include('navbar.html'); echo "</td></tr></table>"; switch ($pg) { case 'note': include('note.html'); break; case 'index': include('start.html'); break; case 'about': include('about.html'); break; case 'links': include('link.html'); break; case 'media': include('media.html'); break; case 'hs': include('helpful.php'); break; case 'other': include('other.html'); break; } include('footer.html'); } pagechange($pg); ?> The problem I've run into: I've started work on the section titled helpful stuff, and it is using a similar form of the above code (I'll put it below so you can see how similar) to do the navigation for the parts of that section. However, I've found that it is not displaying the contents of those pages. I've spent a good deal of time trying to work out the reason for this, but I can't find the problem. subsection navigation: <?php $sp = $_GET['sp']; if($_GET['sp'] == '') { $sp = "info"; } function pageswitch($sp) { echo "<table cols='2' border='0' cellpadding='10' cellspacing='0' align='center' width='100%'>"; echo "<tr>"; echo "<td width='16%'>"; include('./nav/hsnav.html'); echo "</td><td>"; switch ($sp) { case 'info': include('./info/hsinfo.html'); break; case 'bio': include('./info/bioinfo.html'); break; } echo "</tr></table>"; } pageswitch($pg); ?> contents of 'hsinfo.html': This section is dedicated to providing people with helpful little tools to either learn a concept better or get an idea of how something works. Everything seen here is something I have spent time coding myself, so please don't try stealing it. page as it continues to appear: http://ck9.outpost-universe.net/index.php?pg=hs&sp=info I am more than willing to provide other information as needed. Link to comment https://forums.phpfreaks.com/topic/150197-solved-php-nav-system-need-help/ Share on other sites More sharing options...
Zhadus Posted March 19, 2009 Share Posted March 19, 2009 What is the direct link to hsinfo.html or bioinfo.html? I can't find the pages anywhere. If you change it to 'require' instead of 'include' it will throw an error if it cannot find the page. I'd recommend checking that. Link to comment https://forums.phpfreaks.com/topic/150197-solved-php-nav-system-need-help/#findComment-788824 Share on other sites More sharing options...
CK9 Posted March 19, 2009 Author Share Posted March 19, 2009 Tried changing it to require, no error was given, even when I open the helpful.php page itself. http://ck9.outpost-universe.net/info/hsinfo.html is the direct link to hsinfo, the bio info one is currently empty (but will be giving some basic information and a link to something I made that goes through the process of photosynthesis with a dynamic image (bio class project)). Link to comment https://forums.phpfreaks.com/topic/150197-solved-php-nav-system-need-help/#findComment-788831 Share on other sites More sharing options...
Zhadus Posted March 19, 2009 Share Posted March 19, 2009 So incredibly simple, yet I missed it and all of the onlookers did to. Lesson to learn: 'Copy and Paste is the devil' When you call the function on helpful.php you use: pageswitch($pg); it should be: pageswitch($sp); You're giving the pageswitch() function the wrong variable. Link to comment https://forums.phpfreaks.com/topic/150197-solved-php-nav-system-need-help/#findComment-788859 Share on other sites More sharing options...
CK9 Posted March 19, 2009 Author Share Posted March 19, 2009 I hate copy+paste when coding, that's a hand-typed error. Fixed that, tried it, still not working. I added in echo $sp; after the if statement to confirm that it's getting the value. On the helpful.php page itself it displays the value of $sp, but it does not when it goes through the index.php page. Just went through the page code, found out that I forgot that I replaced the include with the page code iteslf to see if that would fix the problem. changed it to a require and it's working fine now... Thanks for the help, I can't believe I didn't catch that in the first place. Link to comment https://forums.phpfreaks.com/topic/150197-solved-php-nav-system-need-help/#findComment-788876 Share on other sites More sharing options...
Zhadus Posted March 19, 2009 Share Posted March 19, 2009 Okay great. Noticed you're new here, check the 'topic solved' towards the bottom of the page. If you have more questions, we'll be glad to help. Sometimes hand typed errors are just as bad one of the reasons I prefer a little bit more exact naming for variables, usually easier to catch. Link to comment https://forums.phpfreaks.com/topic/150197-solved-php-nav-system-need-help/#findComment-788886 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.