Jump to content

[SOLVED] Can you see what's wrong here?


86Stang

Recommended Posts

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

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.

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.