Jump to content

Error


eminempk

Recommended Posts

Hey,

i m a newbie in php,when i run the wamp server i got this error whn i click on my project. but when i click on Home, Gallery etc, then the error is gone i dont know what seems the problem is, help would be appreciated.

 

here is the code of index.php

 

 

<?php

 

include("includes/header.html");

include("includes/navbar1.html");

 

if($_GET["page"] == "design"){

include ("includes/design.html");

}

else if ($_GET["page"] == "gallery"){

include ("includes/gallery.html");

}

 

else if ($_GET["page"] == "contact"){

include ("contact2.html");

}

else if  ($_GET["page"] == "about"){

include ("includes/About.html");

}

else

{

 

include("includes/home.html");

}

include("includes/footer.html");

 

?>

 

It loads the dynamic content, but first when i load it i got these errors as mentioned in the screenshot. 

 

[attachment deleted by admin]

Link to comment
Share on other sites

page is undefined as its not a variable passed in the $_GET when you call the page first off.

wrap the whole if statement in an other if statement that has isset($_GET['page'])

 

personally I would do it this way:

$page;

if (isset($_GET['page']) $page = $_GET['page'];

 

switch ($page) {

    case "design":

        include ("includes/design.html");

break;

    case "gallery":

        include ("includes/gallery.html");

        break;

    case "contact":

        include ("includes/contact.html");

        break;

    default:

        include ("includes/home.html");

 

}

 

 

 

Link to comment
Share on other sites

page is undefined as its not a variable passed in the $_GET when you call the page first off.

wrap the whole if statement in an other if statement that has isset($_GET['page'])

 

personally I would do it this way:

$page;

if (isset($_GET['page']) $page = $_GET['page'];

 

switch ($page) {

    case "design":

        include ("includes/design.html");

break;

    case "gallery":

        include ("includes/gallery.html");

        break;

    case "contact":

        include ("includes/contact.html");

        break;

    default:

        include ("includes/home.html");

 

}

 

I did wht u asked like this but now i get this error;

( ! ) Parse error: syntax error, unexpected T_VARIABLE in C:\wamp server\www\Myweb\index.php on line 7

 

and line 7 is if (isset($_GET['page']) $page = $_GET['page'];

 

 

 

<?php

include("includes/header.html");

include("includes/navbar1.html");

 

$page;

if (isset($_GET['page']) $page = $_GET['page'];

 

switch ($page) {

    case "design":

        include ("includes/design.html");

break;

    case "gallery":

        include ("includes/gallery.html");

        break;

    case "contact":

        include ("includes/contact.html");

        break;

    default:

        include ("includes/home.html");

include("includes/footer.html");

}

 

?>

 

 

 

 

 

 

Link to comment
Share on other sites

yeah sorry a small typo  ::)

 

if (isset($_GET['page'])) $page = $_GET['page']

 

i only closed off one of the )

 

lol now i m getting an error in line 9

 

switch($page) {

 

( ! ) Parse error: syntax error, unexpected T_SWITCH in C:\wamp server\www\Myweb\index.php on line 9

 

can u post me the full code  :shrug:

Link to comment
Share on other sites

hehe sure, sometimes I just overlook the simplest of errors, we are all human

$page='';
if (isset($_GET['page'])) $page = $_GET['page'];

switch ($page) {
    case "design":
         include ("includes/design.html");
break;
    case "gallery":
         include ("includes/gallery.html");
        break;
    case "contact":
         include ("includes/contact.html");
        break;
    default:
         include ("includes/home.html");

}

include("includes/footer.html");

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.