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? Link to comment https://forums.phpfreaks.com/topic/66945-solved-can-you-see-whats-wrong-here/ 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? Link to comment https://forums.phpfreaks.com/topic/66945-solved-can-you-see-whats-wrong-here/#findComment-335712 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? Link to comment https://forums.phpfreaks.com/topic/66945-solved-can-you-see-whats-wrong-here/#findComment-335713 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". Link to comment https://forums.phpfreaks.com/topic/66945-solved-can-you-see-whats-wrong-here/#findComment-335718 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. Link to comment https://forums.phpfreaks.com/topic/66945-solved-can-you-see-whats-wrong-here/#findComment-335728 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? Link to comment https://forums.phpfreaks.com/topic/66945-solved-can-you-see-whats-wrong-here/#findComment-335731 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. Link to comment https://forums.phpfreaks.com/topic/66945-solved-can-you-see-whats-wrong-here/#findComment-335736 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 Link to comment https://forums.phpfreaks.com/topic/66945-solved-can-you-see-whats-wrong-here/#findComment-335749 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!! Link to comment https://forums.phpfreaks.com/topic/66945-solved-can-you-see-whats-wrong-here/#findComment-336252 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.