/    Sign up×
Community /Pin to ProfileBookmark

$_GET for including a file.

Strange to me how a switch case structure works for all switch elements but the last 3.

I have a switch case structure to include files for specific pages. All seem to work but the last 3.

[B]What I’ve tried:[/B]

[LIST]

  • [*]

    removing elements in the Switch Case


  • [*]

    changing GET value to load page


  • [*]

    changing order of switch case elements


  • [*]

    echo values for GET on page loads


  • [*]

    check for syntax errors


  • [*]

    check the page to load is working correctly on its own


  • [/LIST]

    [B]Testing Results[/B]
    When echoing the value of the $_GET showed a value while the ones which didn’t work didn’t show anything.

    Example:

    [code=php]$pgnm=$_GET[“pg”];

    //print out the value of the $_GET
    echo $pgnm;

    switch($pgnm){

    // result = Page1
    case “Page1”:
    include(“inc/page1.php”);
    break;

    // result = Page2
    case “Page2”:
    include(“inc/page2.php”);
    break;

    // result = **no value**
    case “Page3”:
    include(“inc/page3.php”);
    break;

    default:
    include(“inc/page1.php”);
    break;

    }[/code]

    If anyone has any ideas as to what would cause a malfunction like this, I’d appreciate your response.

    to post a comment
    PHP

    2 Comments(s)

    Copy linkTweet thisAlerts:
    @NogDogNov 23.2011 — Shouldn't this...
    [code=php]switch($pgid){ [/code]...be this...
    [code=php]switch($pgnm){ [/code]...?
    Copy linkTweet thisAlerts:
    @sonicpaintauthorNov 23.2011 — Shouldn't this...
    [code=php]switch($pgid){ [/code]...be this...
    [code=php]switch($pgnm){ [/code]...?[/QUOTE]



    lol...sorry that was a typo. I will correct that.
    ×

    Success!

    Help @sonicpaint spread the word by sharing this article on Twitter...

    Tweet This
    Sign in
    Forgot password?
    Sign in with TwitchSign in with GithubCreate Account
    about: ({
    version: 0.1.9 BETA 5.19,
    whats_new: community page,
    up_next: more Davinci•003 tasks,
    coming_soon: events calendar,
    social: @webDeveloperHQ
    });

    legal: ({
    terms: of use,
    privacy: policy
    });
    changelog: (
    version: 0.1.9,
    notes: added community page

    version: 0.1.8,
    notes: added Davinci•003

    version: 0.1.7,
    notes: upvote answers to bounties

    version: 0.1.6,
    notes: article editor refresh
    )...
    recent_tips: (
    tipper: @AriseFacilitySolutions09,
    tipped: article
    amount: 1000 SATS,

    tipper: @Yussuf4331,
    tipped: article
    amount: 1000 SATS,

    tipper: @darkwebsites540,
    tipped: article
    amount: 10 SATS,
    )...