Results 1 to 5 of 5

Thread: parse error :-(

  1. #1
    Join Date
    Mar 2002
    Location
    Montréal CANADA
    Posts
    2,149

    parse error :-(

    Okay I am getting a parse error with this...

    if (!isset($_COOKIE['pkg']) {
    header("Location: http://www.thejehm.net/services/webh...hase/index.php");
    } elseif {
    $_COOKIE['pkg'] = "Single"
    include_once ("single.txt");
    } elseif {
    $_COOKIE['pkg'] = "Double"
    include_once ("double.txt");
    } elseif {
    $_COOKIE['pkg'] = "Triple"
    include_once ("triple.txt");
    } elseif {
    $_COOKIE['pkg'] = "Quad"
    include_once ("quad.txt");
    }
    Here is the code so make it easier -->
    PHP Code:
    <?php
    if (!isset($_COOKIE['pkg']) {
        
    header("Location: http://www.thejehm.net/services/webhosting/purchase/index.php");
    } elseif {
        
    $_COOKIE['pkg'] = "Single"
        
    include_once ("single.txt");
        } elseif {
            
    $_COOKIE['pkg'] = "Double"
            
    include_once ("double.txt");
            } elseif {
                
    $_COOKIE['pkg'] = "Triple"
                
    include_once ("triple.txt");
                } elseif {
                    
    $_COOKIE['pkg'] = "Quad"
                    
    include_once ("quad.txt");
    }
    ?>
    Error =
    Parse error: parse error in /home/httpd/vhosts/thejehm.net/httpdocs/services/webhosting/purchase/step2.php on line 187

  2. #2
    Join Date
    Mar 2002
    Location
    Montréal CANADA
    Posts
    2,149
    OK part of the "bonehead" moment has passed...

    if (!isset($_COOKIE['pkg'])) {
    header("Location: http://www.thejehm.net/services/webhosting/purchase/index.php");
    }

    Is on its own...b/c there really is nothing "else" to do....

    However I think it just has to be that I need to figure out how to get the possible values for the cookie to work...since there are four possibilites...i just want to say that if the cookie = this then print that...

  3. #3
    Join Date
    Feb 2002
    Location
    Washington state, USA
    Posts
    1,355
    That part on its own is fine. For the rest, I would use a "switch". Note that the following two examples do the exact same thing:

    PHP Code:
    if ($i == 0) {
        print 
    "i equals 0";
    }
    if (
    $i == 1) {
        print 
    "i equals 1";
    }
    if (
    $i == 2) {
        print 
    "i equals 2";
    }

    switch (
    $i) {
        case 
    0:
            print 
    "i equals 0";
            break;
        case 
    1:
            print 
    "i equals 1";
            break;
        case 
    2:
            print 
    "i equals 2";
            break;

    Cheers!

    ~no_mac_jack
    "He that would make his own liberty secure must guard even his enemy from oppression." - Thomas Paine

  4. #4
    Join Date
    Feb 2002
    Location
    Washington state, USA
    Posts
    1,355
    BTW - You need the break in there otherwise it will do everything until it hits a break. For example, if you left out the first brake and $i = 0 then it would print "i equals 0" AND "i equals 1" before stopping at the break.

    ~no_mac_jack
    "He that would make his own liberty secure must guard even his enemy from oppression." - Thomas Paine

  5. #5
    Join Date
    Mar 2002
    Location
    Montréal CANADA
    Posts
    2,149
    worked like a charm....cheers

    using a switch never crossed my mind here....thanks again!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •