SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Wizard Dylan B's Avatar
    Join Date
    Jul 2004
    Location
    NYC
    Posts
    1,150
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Can you open an 'if' in a header and close it in the footer?

    Header:
    PHP Code:
    <?php
        
    include 'config.php';
        
    session_start();
    ?>
        <html>
            <head>
                <title>
                    Ebricity!
                </title>
            </head>


    <?php    
        
        
    if (isset($_COOKIE['username']) && isset($_COOKIE['password'])) // Authenticate.
        
    {
            
    $cookieUsername $_COOKIE['username'];
            
    $cookieMD5Password $_COOKIE['password'];
            
    $CheckCookie = @mysql_query('SELECT * FROM players WHERE username = '                 $cookieUsername ' AND password = ' .                         $cookieMD5Password);
            if (
    mysql_num_rows($CheckCookie) != 1)
            {
                include 
    'login.php';
                exit;
            }

            
    $row mysql_fetch_array($CheckCookie);

            
    $username $cookieUsername;
            
    $credits $row['credits'];
            
    $rank $row['rank'];
            
    $frozenmsg $row['frozenmsg'];
            
    $frozenby $row['frozenby'];
                
        
        if (
    $rank == 1)
        {
            echo 
    $frozenmsg "<br />&nbsp;<br />--" $frozenby;
        }

    ?>
    Footer:
    PHP Code:
    <?php
        
    }
        else
        {
            include 
    'login.php';
        }
    ?>
    I'm getting parse errors after the last line of the header, so I assume it's a bracket problem, but this conceivably should work, but it isn't.

  2. #2
    Romans 12:2 codyrockx's Avatar
    Join Date
    Jul 2003
    Location
    Newberg, Oregon
    Posts
    422
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No you can't. PHP requires that you close all if/else/while/do/etc. statements within the page that they were opened.
    Codyrobert.com - Designer and Developer

  3. #3
    SitePoint Wizard Dylan B's Avatar
    Join Date
    Jul 2004
    Location
    NYC
    Posts
    1,150
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Damn


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
  •