I hve tred to do incudescrit with thsi code 55 <?PHP 56 57 if (isset(intval($_GET['ID']))) { if ( 58 $_GET['ID'] == 1) { include 'index.php'; } elseif ( 59 $_GET['ID'] == 2) {include 'design.php'; } elseif ( 60 $_GET['ID'] == 3) {include 'graphics.php'; } elseif ( 61 $_GET['ID'] == 4) {include 'portfolio.php'; } elseif ( 62 $_GET['ID'] == 5) {include 'about.php'; } elseif ( 63 $_GET['ID'] == 6) {include 'contact.php'; } elseif ( 64 $_GET['ID'] == 0) {include 'index.php'; } 65 } else { include 66 'home.php'; } 67 ?> Code (markup): And i get this message Parse error: parse error, unexpected T_STRING, expecting T_VARIABLE or '$' in /mbnet/mydomani/subfolder/subfolder/index.php on line 57 what i shuld do? sorry my bad english!
The problem is that you're passing an integer to isset, not actually checking if the $_GET['ID'] is set. I'd take that intval out. if (isset($_GET['ID'])) { if ( Also, for the comparisons that you're doing, you shouldn't need to convert $_GET['ID'] to an integer. If you do need to convert it, do it separately, and not in the conditional like that.
Edit: Damn, you posted righ before me Jangro You can't check if a return value of a function is set, so if (isset(intval($_GET['ID']))) PHP: won't work. Use something like: $get=intval($_GET['ID']); if (isset($get)) PHP: instead. The complete code would be: 55 <?PHP 56 $get= intval($_GET['ID']); 57 if (isset($get)) { if ( 58 $_GET['ID'] == 1) { include 'index.php'; } elseif ( 59 $_GET['ID'] == 2) {include 'design.php'; } elseif ( 60 $_GET['ID'] == 3) {include 'graphics.php'; } elseif ( 61 $_GET['ID'] == 4) {include 'portfolio.php'; } elseif ( 62 $_GET['ID'] == 5) {include 'about.php'; } elseif ( 63 $_GET['ID'] == 6) {include 'contact.php'; } elseif ( 64 $_GET['ID'] == 0) {include 'index.php'; } 65 } else { include 66 'home.php'; } 67 ?> Code (markup):
i can oppen "new" page design.php i wrote in the link <a href="index.php?ID=2">Thext</a> and it wont work
I would simply do the code this way: if ($_GET['ID'] == 1) { include 'index.php'; } elseif ($_GET['ID'] == 2) {include 'design.php'; } elseif ($_GET['ID'] == 3) {include 'graphics.php'; } elseif ($_GET['ID'] == 4) {include 'portfolio.php'; } elseif ($_GET['ID'] == 5) {include 'about.php'; } elseif ($_GET['ID'] == 6) {include 'contact.php'; } elseif ($_GET['ID'] == 0) {include 'index.php'; } else { include 'home.php'; } Code (markup): This Always works, you really have no need for isset By The way if this is in index.php you can't include itself
for this sort of stuff it's MUCH better and easier to use the PHP switch statement: switch ($_GET['ID']) { case 0: include ("example.php"); break; case 1: include ("example.php"); break; case "this is text": include ("example.php"); break; default: echo "ERROR, ID not found"; break; } You'll notice that you can setup the switch statement to match against integers or strings, it's up to you. ...not to mention the default action that can be added. You don't have to have it but it is a fantastic feature. direct link to the PHP manual's switch statement You'll also notice that I wrote the includes with round brackets and double quotes, I suggest you do this also.
You should definitely go down the switch route. Much more efficient use of your servers resources. You can write; case 0 : case 1 : include 'index.php'; break; since it is doing the same thing for each case. Good luck!