86Stang Posted August 27, 2007 Share Posted August 27, 2007 I have some code that is acting very bizarre and I'm hoping for some help. In PHP before the HTML I have this: if (!isset($opt)) { $opt = "view_event"; } switch(true) { case strstr($opt, "event"): $submenu = "<a href=\"?opt=add_event\" class=\"submenu\">Add an Event</a>"; break; case strstr($opt, "banner"): $submenu = "<a href=\"?opt=add_banner\" class=\"submenu\">Add a Banner</a>"; break; case strstr($opt, "article"): $submenu = "<a href=\"?opt=add_article\" class=\"submenu\">Add an Article</a>"; break; } and in the HTML I have this: <table border="0" cellspacing="0" cellpadding="4"> <tr> <td><b><a href="?opt=view_event" class="menu">View Events</a></b></td> <td><b class="menu">|</b></td> <td><b><a href="?opt=view_banner" class="menu">View Banners</a></b></td> <td><b class="menu">|</b></td> <td><b><a href="?opt=view_article" class="menu">View Articles</a></b></td> </tr> </table> <table> <tr> <td><? echo $submenu; ?></td> </tr> </table> <table> <tr> <td><? include($opt . ".php"); ?></td> </tr> </table> This is basically a menu system where the "View" links are a nav and the "Add" links are submenus. I have view_banner.php, add_banner.php, etc. and It works like a champ but when I put it on a different server the links won't bring up the requested page(s). The only difference between the servers is the one where this code works on has PHP 4.4.2 and the one where it won't has PHP 4.4.4. MySQL versions are identical. I'm wondering if that small of difference could've killed my code? I looked and switch and strstr doesn't appear to be affected since 4.3.x so I'm at a loss why this won't work. Any ideas? Quote Link to comment Share on other sites More sharing options...
socratesone Posted August 27, 2007 Share Posted August 27, 2007 What do you mean it wont work? What are you seeing in 4.4.4? Quote Link to comment Share on other sites More sharing options...
Asperon Posted August 27, 2007 Share Posted August 27, 2007 are your view_banner.php and other files located in the same folder as that page on the other server? Quote Link to comment Share on other sites More sharing options...
lemmin Posted August 27, 2007 Share Posted August 27, 2007 This is a guess, but are short tags enables on the server? http://us.php.net/manual/en/ini.core.php#ini.short-open-tag Try changing your "<?"'s to "<?php". Quote Link to comment Share on other sites More sharing options...
86Stang Posted August 27, 2007 Author Share Posted August 27, 2007 What do you mean it wont work? What are you seeing in 4.4.4? Sorry, I click the links but they won't bring up the requested page. IOW if I click on 'Add an Event' instead of add_event.php coming up, it stays at index.php although in the browser is shows "http://www.mysite/folder/?opt=add_event" which is the exact same thing it shows on the server that works. are your view_banner.php and other files located in the same folder as that page on the other server? Yes. This is a guess, but are short tags enables on the server? http://us.php.net/manual/en/ini.core.php#ini.short-open-tag Try changing your "<?"'s to "<?php". Yeah, they're enabled. I tried changing it just to be sure but didn't get anything different. Quote Link to comment Share on other sites More sharing options...
lemmin Posted August 27, 2007 Share Posted August 27, 2007 What are you using to handle the URL variables? Can you show some of that code in index.php? Quote Link to comment Share on other sites More sharing options...
86Stang Posted August 27, 2007 Author Share Posted August 27, 2007 Other than the opening/closing PHP tags and a 'require' to call in the connection to the DB, you're looking at all the PHP I have in there. Quote Link to comment Share on other sites More sharing options...
AndyB Posted August 27, 2007 Share Posted August 27, 2007 Could be a register_globals issue. Set to ON for the server where it works; set to OFF (the more recent and more secure setting) on the other server. If that's the case, you need to retrieve $opt from the $_GET array, not expect it to exist globally. e.g. $opt = $_GET['opt']; // retrieve passed var in URL Quote Link to comment Share on other sites More sharing options...
86Stang Posted August 28, 2007 Author Share Posted August 28, 2007 That was the culprit AndyB. Thanks so much!! 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.