how to organize includes

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • JRough

    how to organize includes

    I have includes at the top of the file and I have inline includes also
    includes in mysql queries. For example:

    include './includes/config.inc.php' ;
    include $include_path.' dates.inc.php';
    include $include_path.' auction_types.i nc.php';
    include $include_path.' countries.inc.p hp';
    include $include_path.' datacheck.inc.p hp';
    include $include_path.' wordfilter.inc. php';
    include $include_path.' converter.inc.p hp';


    include "header.php ";

    $_SESSION["sessionVar s"]=$sessionVars;
    include "header.php ";
    include phpa_include("t emplate_menu_ph p.html");
    include phpa_include("t emplate_sell_pr eview_php.html" );
    include "footer.php ";
    exit;

    }

    $query = "SELECT * FROM PHPAUCTIONXL_in vitedbuyersrows WHERE list_id=
    $v";
    $resi = @mysql_query($q uery);
    if(!$resi) {
    MySQLError($que ry);
    exit;
    } else {

    while($user = mysql_fetch_arr ay($resi)) {
    $query = "SELECT name,email FROM PHPAUCTIONXL_us ers WHERE id='".
    $user["buyer_id"]."'";
    //print $query."<br />";
    $resu = @mysql_query($q uery);
    if(!$resu) {
    mySQLError($que ry);
    exit;
    } elseif(mysql_nu m_rows($resu) 0) {

    $BUYER_EMAIL = mysql_result($r esu,0,"email");
    $BUYER_NAME = mysql_result($r esu,0,"name");
    include $include_path." invitation_emai l.inc.php";

    }
    }
    }
    }
    }

    What I want to know is how to organize it? I don't have a
    template. Is that what this directory is for:
    include './includes/config.inc.php' ;
    How do I
    know which includes need to be in the directory and which includes
    must be in-line?:

    Also, I read that require() is better than include(). Should I change
    all includes to require?


    Thanks,
  • AnrDaemon

    #2
    Re: how to organize includes

    Greetings, JRough.
    In reply to Your message dated Tuesday, May 13, 2008, 01:31:49,
    $_SESSION["sessionVar s"]=$sessionVars;
    Interesting code.
    include "header.php ";
    And You're including header.php twice.
    Do you know what You doing?
    What I want to know is how to organize it?
    You are free to use any way You prefer. It's obvious.
    General recommendation is to have included code stored outside of web root.
    How do I know which includes need to be in the directory and which includes
    must be in-line?:
    Me laughing loudly.
    Your question meaningless.
    You can place included files anywhere if You can access that place from the
    PHP at runtime.
    Also, I read that require() is better than include(). Should I change
    all includes to require?
    Word "better" has relative meaning. Define Your needs first.
    And I would seriously recommend You to ACTUALLY READ PHP documentation in the
    part of include/require explanation.
    It is quite clear.


    --
    Sincerely Yours, AnrDaemon <anrdaemon@free mail.ru>

    Comment

    Working...