Problem including the other php file.

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

    Problem including the other php file.

    Hi,

    I want to include three php files in index.php file like the code below. But
    it always shows up only two, any two of the three, any order.

    <tr>
    <td><?php include ("includes/documents.php") ; ?>&nbsp;</td>
    </tr>
    <tr>
    <td><?php include ("includes/locations.php") ; ?>&nbsp;</td>
    </tr>
    <tr>
    <td><?php include ("includes/status.php"); ?>&nbsp;</td>
    </tr>

    Can anyone help me out?

    Ben


  • vinnie

    #2
    Re: Problem including the other php file.

    On Jun 8, 11:07 am, "Ben Sehara" <seh...@hotmail .comwrote:
    Hi,
    >
    I want to include three php files in index.php file like the code below. But
    it always shows up only two, any two of the three, any order.
    >
    <tr>
    <td><?php include ("includes/documents.php") ; ?</td>
    </tr>
    <tr>
    <td><?php include ("includes/locations.php") ; ?</td>
    </tr>
    <tr>
    <td><?php include ("includes/status.php"); ?</td>
    </tr>
    >
    Can anyone help me out?
    >
    Ben
    Hi Ben,
    the include() statement works in the same way of require(), with the
    difference that require() is executed the first time the statement is
    parsed, while include() is evluated each time the statement is
    executed.

    you may wanna work in this way:

    <?php

    if (variable == true)
    {
    include('file.i nc');
    }
    else
    {
    echo 'hello!';
    }
    ?>

    bye,
    V.

    Comment

    • ZeldorBlat

      #3
      Re: Problem including the other php file.

      On Jun 8, 11:30 am, vinnie <centro.ga...@g mail.comwrote:
      On Jun 8, 11:07 am, "Ben Sehara" <seh...@hotmail .comwrote:
      >
      >
      >
      Hi,
      >
      I want to include three php files in index.php file like the code below. But
      it always shows up only two, any two of the three, any order.
      >
      <tr>
      <td><?php include ("includes/documents.php") ; ?</td>
      </tr>
      <tr>
      <td><?php include ("includes/locations.php") ; ?</td>
      </tr>
      <tr>
      <td><?php include ("includes/status.php"); ?</td>
      </tr>
      >
      Can anyone help me out?
      >
      Ben
      >
      Hi Ben,
      the include() statement works in the same way of require(), with the
      difference that require() is executed the first time the statement is
      parsed, while include() is evluated each time the statement is
      executed.
      >
      Umm, not quite. require() and include() are identical in every way
      except for how they handle failure. If the file cannot be included
      for some reason, require() will cause the entire script to die while
      include will just throw a warning.

      Comment

      • vinnie

        #4
        Re: Problem including the other php file.

        On Jun 8, 11:38 am, ZeldorBlat <zeldorb...@gma il.comwrote:
        On Jun 8, 11:30 am, vinnie <centro.ga...@g mail.comwrote:
        >
        >
        >
        On Jun 8, 11:07 am, "Ben Sehara" <seh...@hotmail .comwrote:
        >
        Hi,
        >
        I want to include three php files in index.php file like the code below. But
        it always shows up only two, any two of the three, any order.
        >
        <tr>
        <td><?php include ("includes/documents.php") ; ?</td>
        </tr>
        <tr>
        <td><?php include ("includes/locations.php") ; ?</td>
        </tr>
        <tr>
        <td><?php include ("includes/status.php"); ?</td>
        </tr>
        >
        Can anyone help me out?
        >
        Ben
        >
        Hi Ben,
        the include() statement works in the same way of require(), with the
        difference that require() is executed the first time the statement is
        parsed, while include() is evluated each time the statement is
        executed.
        >
        Umm, not quite. require() and include() are identical in every way
        except for how they handle failure. If the file cannot be included
        for some reason, require() will cause the entire script to die while
        include will just throw a warning.
        Correct! :)

        Comment

        • Tom

          #5
          Re: Problem including the other php file.


          "vinnie" <centro.gamma@g mail.comwrote in message
          news:1181321595 .298753.168100@ n4g2000hsb.goog legroups.com...
          On Jun 8, 11:38 am, ZeldorBlat <zeldorb...@gma il.comwrote:
          On Jun 8, 11:30 am, vinnie <centro.ga...@g mail.comwrote:


          On Jun 8, 11:07 am, "Ben Sehara" <seh...@hotmail .comwrote:
          Hi,
          I want to include three php files in index.php file like the code
          below. But
          it always shows up only two, any two of the three, any order.
          <tr>
          <td><?php include ("includes/documents.php") ; ?</td>
          </tr>
          <tr>
          <td><?php include ("includes/locations.php") ; ?</td>
          </tr>
          <tr>
          <td><?php include ("includes/status.php"); ?</td>
          </tr>
          Can anyone help me out?
          Ben
          Hi Ben,
          the include() statement works in the same way of require(), with the
          difference that require() is executed the first time the statement is
          parsed, while include() is evluated each time the statement is
          executed.
          Umm, not quite. require() and include() are identical in every way
          except for how they handle failure. If the file cannot be included
          for some reason, require() will cause the entire script to die while
          include will just throw a warning.
          >
          Correct! :)
          >
          If you wanted to test for error messages for debugging purposes, is there a
          way to redirect required() fatal errors to error_log? Was trying to find the
          best way for them to track why all three includes weren't working. Would
          required() just output the fatal error to the web page?

          Tom
          --
          Newsguy.com - Basic Accounts $39.95 / 12 months





          Comment

          • ZeldorBlat

            #6
            Re: Problem including the other php file.

            On Jun 8, 1:40 pm, "Tom" <t...@to.comwro te:
            "vinnie" <centro.ga...@g mail.comwrote in message
            >
            news:1181321595 .298753.168100@ n4g2000hsb.goog legroups.com...
            >
            >
            >
            On Jun 8, 11:38 am, ZeldorBlat <zeldorb...@gma il.comwrote:
            On Jun 8, 11:30 am, vinnie <centro.ga...@g mail.comwrote:
            >
            On Jun 8, 11:07 am, "Ben Sehara" <seh...@hotmail .comwrote:
            >
            Hi,
            >
            I want to include three php files in index.php file like the code
            below. But
            it always shows up only two, any two of the three, any order.
            >
            <tr>
            <td><?php include ("includes/documents.php") ; ?</td>
            </tr>
            <tr>
            <td><?php include ("includes/locations.php") ; ?</td>
            </tr>
            <tr>
            <td><?php include ("includes/status.php"); ?</td>
            </tr>
            >
            Can anyone help me out?
            >
            Ben
            >
            Hi Ben,
            the include() statement works in the same way of require(), with the
            difference that require() is executed the first time the statement is
            parsed, while include() is evluated each time the statement is
            executed.
            >
            Umm, not quite. require() and include() are identical in every way
            except for how they handle failure. If the file cannot be included
            for some reason, require() will cause the entire script to die while
            include will just throw a warning.
            >
            Correct! :)
            >
            If you wanted to test for error messages for debugging purposes, is there a
            way to redirect required() fatal errors to error_log? Was trying to find the
            best way for them to track why all three includes weren't working. Would
            required() just output the fatal error to the web page?
            >
            Tom
            --
            Newsguy.com - Basic Accounts $39.95 / 12 months
            It will be reported if you have error_reporting () turned up
            sufficiently. It will be displayed in the output if you have
            display_errors enabled in php.ini.

            Comment

            • Jon Slaughter

              #7
              Re: Problem including the other php file.


              "Ben Sehara" <sehara@hotmail .comwrote in message
              news:vgeai.1996 9$j63.6950@news read2.news.pas. earthlink.net.. .
              Hi,
              >
              I want to include three php files in index.php file like the code below.
              But it always shows up only two, any two of the three, any order.
              >
              <tr>
              <td><?php include ("includes/documents.php") ; ?>&nbsp;</td>
              </tr>
              <tr>
              <td><?php include ("includes/locations.php") ; ?>&nbsp;</td>
              </tr>
              <tr>
              <td><?php include ("includes/status.php"); ?>&nbsp;</td>
              </tr>
              >
              Can anyone help me out?
              >

              Strange... I would imagine that the order matters..

              replace include with echo and see if it still has the same problem...

              If not then replace your includes wiht simple files like

              i.e. document.php =>
              echo '1';
              locations.php =>
              echo '2';
              ....



              and see if it still does the same thing. (try to narrow down the issue... if
              if its what you have in your includes or if its the include statement
              itself)

              Its very strange that the order doesn't matter cause php starts from the top
              down... the first include is included first so if it doesn't get included
              some of the time then something very strange is going on or its some logical
              issue in your php files.



              Comment

              • Ben Sehara

                #8
                Re: Problem including the other php file.

                I included the same and simple php file three times. It still shows the
                first two. I checked the source. It is like this.

                =============== =============== =============== =============== =======
                <table width="760" align="center">
                <tr>
                <td>First Table Here</td>
                </tr>
                <tr>
                <td>
                <!-- start of documents.php -->
                <table width="70%">
                <tr>
                <td width="33%"><a href="./docs/doc1.pdf">Doc1</a></td>
                <td width="33%"><a href="./docs/doc2.pdf">Doc2</a></td>
                <td width="33%"><a href="./docs/doc3.pdf">Doc3</a></td>
                </tr>
                <tr>
                <td width="33%"><a href="./docs/doc4.pdf">Doc4</a></td>
                </tr>
                </table>
                <!-- end of documents.php -->
                </td>
                </tr>
                <tr>
                <td>Second Table Here</td>
                </tr>
                <tr>
                <td>
                <!-- start of documents.php -->
                <table width="70%">
                <tr>
                <td width="33%"><a href="./docs/doc1.pdf">Doc1</a></td>
                <td width="33%"><a href="./docs/doc2.pdf">Doc2</a></td>
                <td width="33%"><a href="./docs/doc3.pdf">Doc3</a></td>
                </tr>
                <tr>
                <td width="33%"><a href="./docs/doc4.pdf">Doc4</a></td>
                </tr>
                </table>
                <!-- end of documents.php -->
                =============== =============== =============== =============== =======
                The following is missing.

                </td>
                </tr>
                <tr>
                <td>Third Table Here</td>
                </tr>
                <tr>
                <td>
                <!-- start of documents.php -->
                <table width="70%">
                <tr>
                <td width="33%"><a href="./docs/doc1.pdf">Doc1</a></td>
                <td width="33%"><a href="./docs/doc2.pdf">Doc2</a></td>
                <td width="33%"><a href="./docs/doc3.pdf">Doc3</a></td>
                </tr>
                <tr>
                <td width="33%"><a href="./docs/doc4.pdf">Doc4</a></td>
                </tr>
                </table>
                <!-- end of documents.php -->
                </td>
                </tr>
                </table>

                The included file itself is showing right, but it stopped right after the
                second included file. The documents.php file seems to be fine. Something
                wrong with html tag? It's very simple though.

                Ben


                "Jon Slaughter" <Jon_Slaughter@ Hotmail.comwrot e in message
                news:bUiai.745$ TC1.500@newssvr 17.news.prodigy .net...
                >
                "Ben Sehara" <sehara@hotmail .comwrote in message
                news:vgeai.1996 9$j63.6950@news read2.news.pas. earthlink.net.. .
                >Hi,
                >>
                >I want to include three php files in index.php file like the code below.
                >But it always shows up only two, any two of the three, any order.
                >>
                > <tr>
                > <td><?php include ("includes/documents.php") ; ?>&nbsp;</td>
                > </tr>
                > <tr>
                > <td><?php include ("includes/locations.php") ; ?>&nbsp;</td>
                > </tr>
                > <tr>
                > <td><?php include ("includes/status.php"); ?>&nbsp;</td>
                > </tr>
                >>
                >Can anyone help me out?
                >>
                >
                >
                Strange... I would imagine that the order matters..
                >
                replace include with echo and see if it still has the same problem...
                >
                If not then replace your includes wiht simple files like
                >
                i.e. document.php =>
                echo '1';
                locations.php =>
                echo '2';
                ...
                >
                >
                >
                and see if it still does the same thing. (try to narrow down the issue...
                if if its what you have in your includes or if its the include statement
                itself)
                >
                Its very strange that the order doesn't matter cause php starts from the
                top down... the first include is included first so if it doesn't get
                included some of the time then something very strange is going on or its
                some logical issue in your php files.
                >
                >
                >

                Comment

                • Jon Slaughter

                  #9
                  Re: Problem including the other php file.


                  "Ben Sehara" <sehara@hotmail .comwrote in message
                  news:E4sai.1864 8$Ut6.8507@news read1.news.pas. earthlink.net.. .
                  >I included the same and simple php file three times. It still shows the
                  >first two. I checked the source. It is like this.
                  >
                  Its very important if its the "first two" or "any two". In any two that
                  means its random which means its much harder. If its the first two then it
                  means that its probably something simple. Your code is bugging out after the
                  second one.
                  =============== =============== =============== =============== =======
                  <table width="760" align="center">
                  <tr>
                  <td>First Table Here</td>
                  </tr>
                  <tr>
                  <td>
                  <!-- start of documents.php -->
                  <table width="70%">
                  <tr>
                  <td width="33%"><a href="./docs/doc1.pdf">Doc1</a></td>
                  <td width="33%"><a href="./docs/doc2.pdf">Doc2</a></td>
                  <td width="33%"><a href="./docs/doc3.pdf">Doc3</a></td>
                  </tr>
                  <tr>
                  <td width="33%"><a href="./docs/doc4.pdf">Doc4</a></td>
                  </tr>
                  </table>
                  <!-- end of documents.php -->
                  </td>
                  </tr>
                  <tr>
                  <td>Second Table Here</td>
                  </tr>
                  <tr>
                  <td>
                  <!-- start of documents.php -->
                  <table width="70%">
                  <tr>
                  <td width="33%"><a href="./docs/doc1.pdf">Doc1</a></td>
                  <td width="33%"><a href="./docs/doc2.pdf">Doc2</a></td>
                  <td width="33%"><a href="./docs/doc3.pdf">Doc3</a></td>
                  </tr>
                  <tr>
                  <td width="33%"><a href="./docs/doc4.pdf">Doc4</a></td>
                  </tr>
                  </table>
                  <!-- end of documents.php -->
                  =============== =============== =============== =============== =======
                  The following is missing.
                  >
                  </td>
                  </tr>
                  <tr>
                  <td>Third Table Here</td>
                  </tr>
                  <tr>
                  <td>
                  <!-- start of documents.php -->
                  <table width="70%">
                  <tr>
                  <td width="33%"><a href="./docs/doc1.pdf">Doc1</a></td>
                  <td width="33%"><a href="./docs/doc2.pdf">Doc2</a></td>
                  <td width="33%"><a href="./docs/doc3.pdf">Doc3</a></td>
                  </tr>
                  <tr>
                  <td width="33%"><a href="./docs/doc4.pdf">Doc4</a></td>
                  </tr>
                  </table>
                  <!-- end of documents.php -->
                  </td>
                  </tr>
                  </table>
                  >
                  The included file itself is showing right, but it stopped right after the
                  second included file. The documents.php file seems to be fine. Something
                  wrong with html tag? It's very simple though.
                  >
                  Looks like your creating an error in documents.php(l ast few lines probably)
                  that is causing execution to stop. Happens all the time.

                  Very simple test to find problem... Remove the code that is including the
                  php files(just comment it out) and see if HTML is displaying properly(but
                  without the included stuff). If so then its your php files.

                  or better yet, make very simple php files like I said before that just echo
                  out stuff and then check the html again.

                  Essentially you need to add "markers" to see where the error is occuring.
                  You put "mile markers" in your code and you can narrow down the issue by
                  finding out the last message that was shown.

                  Jon


                  Comment

                  • Ben Sehara

                    #10
                    Re: Problem including the other php file.

                    Sorry, I didn't mention what I have done. I removed the include file and
                    simple html worked fine. I replaced the include file with echo statement and
                    it worked fine.

                    Then, I replaced the echo statement with the include files, only the first
                    and second one worked fine.

                    I switched the first one with the third (not visible) one, again, the first
                    two files worked fine. This first one was not visible before. Any first two
                    include files worked fine even if you switch the files.

                    I tried the different include file in three places. Again, the first two
                    files worded fine.

                    Now I combined those files into one include file. It is OK for now. But if I
                    can find the resolution, I post it here.

                    Thanks for your help.

                    Ben


                    "Jon Slaughter" <Jon_Slaughter@ Hotmail.comwrot e in message
                    news:7Uwai.1688 6$C96.12152@new ssvr23.news.pro digy.net...
                    >
                    "Ben Sehara" <sehara@hotmail .comwrote in message
                    news:E4sai.1864 8$Ut6.8507@news read1.news.pas. earthlink.net.. .
                    >>I included the same and simple php file three times. It still shows the
                    >>first two. I checked the source. It is like this.
                    >>
                    >
                    Its very important if its the "first two" or "any two". In any two that
                    means its random which means its much harder. If its the first two then it
                    means that its probably something simple. Your code is bugging out after
                    the second one.
                    >
                    >============== =============== =============== =============== ========
                    ><table width="760" align="center">
                    ><tr>
                    > <td>First Table Here</td>
                    ></tr>
                    ><tr>
                    > <td>
                    > <!-- start of documents.php -->
                    > <table width="70%">
                    > <tr>
                    > <td width="33%"><a href="./docs/doc1.pdf">Doc1</a></td>
                    > <td width="33%"><a href="./docs/doc2.pdf">Doc2</a></td>
                    > <td width="33%"><a href="./docs/doc3.pdf">Doc3</a></td>
                    > </tr>
                    > <tr>
                    > <td width="33%"><a href="./docs/doc4.pdf">Doc4</a></td>
                    > </tr>
                    > </table>
                    > <!-- end of documents.php -->
                    > </td>
                    ></tr>
                    ><tr>
                    > <td>Second Table Here</td>
                    ></tr>
                    ><tr>
                    > <td>
                    > <!-- start of documents.php -->
                    > <table width="70%">
                    > <tr>
                    > <td width="33%"><a href="./docs/doc1.pdf">Doc1</a></td>
                    > <td width="33%"><a href="./docs/doc2.pdf">Doc2</a></td>
                    > <td width="33%"><a href="./docs/doc3.pdf">Doc3</a></td>
                    > </tr>
                    > <tr>
                    > <td width="33%"><a href="./docs/doc4.pdf">Doc4</a></td>
                    > </tr>
                    > </table>
                    > <!-- end of documents.php -->
                    >============== =============== =============== =============== ========
                    >The following is missing.
                    >>
                    > </td>
                    ></tr>
                    ><tr>
                    > <td>Third Table Here</td>
                    ></tr>
                    ><tr>
                    > <td>
                    > <!-- start of documents.php -->
                    > <table width="70%">
                    > <tr>
                    > <td width="33%"><a href="./docs/doc1.pdf">Doc1</a></td>
                    > <td width="33%"><a href="./docs/doc2.pdf">Doc2</a></td>
                    > <td width="33%"><a href="./docs/doc3.pdf">Doc3</a></td>
                    > </tr>
                    > <tr>
                    > <td width="33%"><a href="./docs/doc4.pdf">Doc4</a></td>
                    > </tr>
                    > </table>
                    > <!-- end of documents.php -->
                    > </td>
                    ></tr>
                    ></table>
                    >>
                    >The included file itself is showing right, but it stopped right after the
                    >second included file. The documents.php file seems to be fine. Something
                    >wrong with html tag? It's very simple though.
                    >>
                    >
                    Looks like your creating an error in documents.php(l ast few lines
                    probably) that is causing execution to stop. Happens all the time.
                    >
                    Very simple test to find problem... Remove the code that is including the
                    php files(just comment it out) and see if HTML is displaying properly(but
                    without the included stuff). If so then its your php files.
                    >
                    or better yet, make very simple php files like I said before that just
                    echo out stuff and then check the html again.
                    >
                    Essentially you need to add "markers" to see where the error is occuring.
                    You put "mile markers" in your code and you can narrow down the issue by
                    finding out the last message that was shown.
                    >
                    Jon
                    >

                    Comment

                    • Schraalhans Keukenmeester

                      #11
                      Re: Problem including the other php file.

                      At Sat, 09 Jun 2007 18:04:46 +0000, Ben Sehara let h(is|er) monkeys type:
                      Sorry, I didn't mention what I have done. I removed the include file and
                      simple html worked fine. I replaced the include file with echo statement and
                      it worked fine.
                      >
                      Then, I replaced the echo statement with the include files, only the first
                      and second one worked fine.
                      >
                      I switched the first one with the third (not visible) one, again, the first
                      two files worked fine. This first one was not visible before. Any first two
                      include files worked fine even if you switch the files.
                      >
                      I tried the different include file in three places. Again, the first two
                      files worded fine.
                      >
                      Now I combined those files into one include file. It is OK for now. But if I
                      can find the resolution, I post it here.
                      >
                      Thanks for your help.
                      >
                      Ben
                      Just guessing here, could it be the case you are (re)defining functions or
                      classes in more than one include file? As suggested, set
                      error_reporting (ALL) in your script and display_errors to on (pref. in
                      php.ini)

                      Finally, Ben, please write your replies BELOW the message you are replying
                      to. Top-posting isn't considered good usenet practice.

                      Good luck,
                      Sh.

                      --
                      Schraalhans Keukenmeester - schraalhans@the .Spamtrapexampl e.nl
                      [Remove the lowercase part of Spamtrap to send me a message]

                      "strcmp('apples ','oranges') < 0"

                      Comment

                      Working...