Conflicting PHP codes

Discussion in 'Troubleshooting' started by eqewebmaster, Aug 5, 2009.

  1. eqewebmaster

    eqewebmaster New Member

    Joined:
    Jun 29, 2009
    Messages:
    21
    I have aMember Pro code protecting some site pages, however I also have some PHPNews php code in my body as my news engine.

    The two codes are conflicting. When I have my php_include code at the top of the html sheet, I get header errors:


    When I remove the following code from the top of the html sheet (which starts at Line 1, as per the aMember instructions),:

    PHP:
    <?php session_start(); ?>
    <?php
    $_product_id 
    = array(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24); 
    require_once 
    '/home/content/a/v/i/MYSITE/plugins/protect/php_include/check.inc.php';
    ?>
    the header errors are gone from my page, however I am of course logged out.



    Here is all the code:

    the aMember Login code
    PHP:
    <?php
    if ($au=$_SESSION['_amember_user']){ // user is logged-in
    print "Hello $au[name_f] $au[name_l]!<br>";
    print 
    "<a href='http://www.MYSITE/member.php'>Member Info</a><br>";
    print 
    "<a href='http://www.MYSITE/logout.php'>Logout</a>";
    } else { 
    // user is not logged-in
    print "<form method=post action='http://www.MYSITE/login.php'>
    Username: <input type=text name=amember_login size=10><br>
    Password: <input type=password name=amember_pass size=10><br>
    <input type=submit value='Login'>
    </form>"
    ;
    }
    ?>
    And here's the PHPNews code:
    PHP:
    <?php
    print<<<EOT
    <h1 id="ni$news[id]">
       
    $subject
    </h1><br>
    <p>
       
    $time by <a href="mailto:$email">$username</a> in $category$caticon
    </p>
    <p>
       <strong>
    $titletext</strong>
    </p>
    <p>
       
    $maintext 
       <br/ ><br/ >| 
    $comments | $sendtofriend | $views views
    </p>
    <hr />
    <br />
    EOT;
    ?>
  2. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,279
    session_start() line should be placed at the top of the file. Before any other output or html code. Error means that you have html code or any other output before session_start()
  3. eqewebmaster

    eqewebmaster New Member

    Joined:
    Jun 29, 2009
    Messages:
    21
    Thanks for the prompt reply, Alexander.

    The session_start() is at Line 1 of my html sheet. However, I believe I found the problem elsewhere. My news engine feed was in a php_require code in the body, and I had that set to a URL, not a relative path. By resetting it to the path, everything appears to be working now.

Share This Page