ev5unleash Posted February 3, 2009 Share Posted February 3, 2009 Hi, I've recently updated my PHP server and when I did this I've had a couple of problems with the script switch(strtolower($_GET['id'])) // 'content' before when I used this code I didn't get a notice message of an Undefined index. Does anyone have an alternative code for this one? Currently using: 5.2.8 Full PHP Code <?php include('./indextop.php'); // header switch(strtolower($_GET['id'])) // 'content' { case "page2": include("pages/page2.php"); break; case "spage1": include("pagespage1.php"); break; default: include("indexhome.php"); break; } include('./indexbottom.php'); // footer ?> Link to comment https://forums.phpfreaks.com/topic/143552-php-problem-after-php-update/ Share on other sites More sharing options...
trq Posted February 3, 2009 Share Posted February 3, 2009 You need to wrap your code in an of. eg; if (isset($_GET['id'])) { // your switch } else { include "indexhome.php"; } Link to comment https://forums.phpfreaks.com/topic/143552-php-problem-after-php-update/#findComment-753120 Share on other sites More sharing options...
ev5unleash Posted February 3, 2009 Author Share Posted February 3, 2009 I'm still getting this same error Notice: Undefined index: id in C:\wamp\www\index.php on line 5 Link to comment https://forums.phpfreaks.com/topic/143552-php-problem-after-php-update/#findComment-753127 Share on other sites More sharing options...
trq Posted February 3, 2009 Share Posted February 3, 2009 Post your code and a pointer to line 5. Link to comment https://forums.phpfreaks.com/topic/143552-php-problem-after-php-update/#findComment-753137 Share on other sites More sharing options...
killah Posted February 3, 2009 Share Posted February 3, 2009 switch(strtolower(isset($_GET['id']))) // 'content' Link to comment https://forums.phpfreaks.com/topic/143552-php-problem-after-php-update/#findComment-753143 Share on other sites More sharing options...
trq Posted February 3, 2009 Share Posted February 3, 2009 switch(strtolower(isset($_GET['id']))) // 'content' isset returns a booleen so that code is of no use at all I'm afraid. Link to comment https://forums.phpfreaks.com/topic/143552-php-problem-after-php-update/#findComment-753145 Share on other sites More sharing options...
killah Posted February 3, 2009 Share Posted February 3, 2009 I would normaly use something like this: if( !isset($_GET['id']) ) { $xid = 'default'; } else { $xid = strtolower($_GET['id']); } switch($xid) { case 'default': include('indexhome.php'); break; case 'page2': include('pages/page2'); break; case 'spage1: include('pagespage1.php'; break; } include('./indexbottom.php'); Link to comment https://forums.phpfreaks.com/topic/143552-php-problem-after-php-update/#findComment-753154 Share on other sites More sharing options...
ev5unleash Posted February 19, 2009 Author Share Posted February 19, 2009 Thanks all for the help, the problem was fixed when I applied the base of killah's code. Link to comment https://forums.phpfreaks.com/topic/143552-php-problem-after-php-update/#findComment-766498 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.