Jump to content

[SOLVED] Switch function trouble.


n00bert

Recommended Posts

<?php
   switch($page)
   {
/*
      case "quotes":
         include 'quotes.php';
      break;
*/
      case "msgs":
         include 'messages.php';
      break;
      default:
         include 'quotes.php';   }
?>

 

Default clause should be last and doesnt require a break; after it. Assuming your cases arent testing for constants you need to quote the strings, if you were using defined constants, remove the quotes I added.

 

//* EDIT

 

No point in having a case that gives the same result as your default clause...

ok seven you were correct. I tried to echo $page and I got nothing. So I enabled register_globals in my php.ini and now everything works.

 

Andy thanks you as well for the advice.

 

BTW.. should I not enable register globals? is there a better way around this?

 

Yes, register_globals is BAD.

 

instead of $page use $_GET['page'] or $_POST['page']....depending on which one you're using

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.