Multiple Include dosent work ???

Discussion in 'PHP' started by fundoobuddy, Jul 2, 2009.

  1. #1
    i am trying to include two different files in a same dir consecutevly but somehow onyl one is being included. it includes the first one it encounters.

    that is

    include("./files/file1.php");
    include("./files/file2.php");

    ^^In this case File1 is included.

    include("./files/file2.php");
    include("./files/file1.php");

    ^^Here file2 is included.


    Any Guesses ???
     
    fundoobuddy, Jul 2, 2009 IP
  2. Bohra

    Bohra Prominent Member

    Messages:
    12,573
    Likes Received:
    537
    Best Answers:
    0
    Trophy Points:
    310
    #2
    Well both are meant to be be included

    try using require instead of include
     
    Bohra, Jul 2, 2009 IP
  3. fundoobuddy

    fundoobuddy Peon

    Messages:
    274
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Nope this dosent help.

    my code is something link this ::

    include("./template/header.php");
    include("./includes/file1.php");
    include("./includes/file2.php");
    include("./template/footer.php");
    PHP:
    In above file2 is not included and not even footer

    but if i comment the third line then footer is include. same thing happens if i change the order of file1 and file2.:confused:
     
    fundoobuddy, Jul 2, 2009 IP
  4. Wrighty

    Wrighty Peon

    Messages:
    199
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Is there an error in one of your included files?
     
    Wrighty, Jul 2, 2009 IP
  5. fundoobuddy

    fundoobuddy Peon

    Messages:
    274
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #5
    nope, i have tested them seperately.
     
    fundoobuddy, Jul 2, 2009 IP
  6. Bohra

    Bohra Prominent Member

    Messages:
    12,573
    Likes Received:
    537
    Best Answers:
    0
    Trophy Points:
    310
    #6
    maybe file1 and file2 say to exit somewhere can u paste the code here
     
    Bohra, Jul 2, 2009 IP
  7. fundoobuddy

    fundoobuddy Peon

    Messages:
    274
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Theres no exit or Die anywhere in file1 and file2 (The code in them is almost equal).
    this can also be proved from the fact that Footer is included once one of the include (file1 or file2 ) is commented.

    sorry i cannot post the code. really sorry for that. i can post more details abt them.
    Majourly Use cURL and explode functions.
     
    fundoobuddy, Jul 2, 2009 IP
  8. Wrighty

    Wrighty Peon

    Messages:
    199
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Could you paste the codes for all of the files please? :)
     
    Wrighty, Jul 2, 2009 IP
  9. fundoobuddy

    fundoobuddy Peon

    Messages:
    274
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #9
    sorry but i really cannot put the Code. i have tried all different things possible even used include_once and all that but things are the same.
     
    fundoobuddy, Jul 2, 2009 IP
  10. www.amagit.com

    www.amagit.com Peon

    Messages:
    87
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #10
    When including the separate files they may not work together if they contain any of the same variable names. They would work alright separately but then would be messed up based on which variables are defined already. Since include pulls the files together as one, it executes as one and sometimes introduces new problems.
     
    www.amagit.com, Jul 2, 2009 IP
  11. fundoobuddy

    fundoobuddy Peon

    Messages:
    274
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #11
    thanks buddy, that explained everything.

    Solved :D
     
    fundoobuddy, Jul 2, 2009 IP