Two PHP Scripts on same page?

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

    Two PHP Scripts on same page?

    Hello,

    I have two small PHP scripts running on a test page at:


    Both scripts work perfectly when there is one script on a page. However, if
    I place two on the page (one above the other), the second script will not
    render. I get no PHP error messages - the script will just not render.

    I think the PHP Scripts are OK as they were automatically generated by RSS
    Feed Burner and both do run separately.

    There may be an issue with having separate calls of some kind on the page or
    my server might not be set right. I did a server test that I think shows
    that it is OK but I am not sure. The results table is at
    http://www.usernomics.com/ergonomic-...ries-test.html . The
    only think I have in my htaccess file for PHP is: "AddType
    application/x-httpd-php .htm .html" .

    I am new to PHP and was wondering if anyone can see why both scripts will
    not run together?

    Thanks a lot,

    Bob


  • juglesh

    #2
    Re: Two PHP Scripts on same page?



    ergobob wrote:[color=blue]
    > Hello,
    >
    > I have two small PHP scripts running on a test page at:
    > http://www.usernomics.com/ergonomic-...essories5.html
    >
    > Both scripts work perfectly when there is one script on a page. However, if
    > I place two on the page (one above the other), the second script will not
    > render. I get no PHP error messages - the script will just not render.[/color]

    Its cuz both scripts have a <body></body> It seems to render ok here
    in IE, in FF its all wierd, like the divs are overlapping. Probly in
    your browser, its stopping at the first </body>.

    --
    juglesh

    Comment

    • ergobob

      #3
      Re: Two PHP Scripts on same page?


      "juglesh" <jugleshjunk@ho tmail.com> wrote in message
      news:1122396557 .031371.200820@ f14g2000cwb.goo glegroups.com.. .[color=blue]
      >
      >
      > ergobob wrote:[color=green]
      >> Hello,
      >>
      >> I have two small PHP scripts running on a test page at:
      >> http://www.usernomics.com/ergonomic-...essories5.html
      >>
      >> Both scripts work perfectly when there is one script on a page. However,
      >> if
      >> I place two on the page (one above the other), the second script will not
      >> render. I get no PHP error messages - the script will just not render.[/color]
      >
      > Its cuz both scripts have a <body></body> It seems to render ok here
      > in IE, in FF its all wierd, like the divs are overlapping. Probly in
      > your browser, its stopping at the first </body>.
      >
      > --
      > juglesh
      >[/color]

      Thanks for the information juglesh. I am new to all of this. How would you
      change that to make it work?

      Thanks,

      Bob


      Comment

      • juglesh

        #4
        Re: Two PHP Scripts on same page?



        ergobob wrote:[color=blue]
        > "juglesh" <jugleshjunk@ho tmail.com> wrote in message
        > news:1122396557 .031371.200820@ f14g2000cwb.goo glegroups.com.. .[color=green]
        > >
        > >
        > > ergobob wrote:[color=darkred]
        > >> Hello,
        > >>
        > >> I have two small PHP scripts running on a test page at:
        > >> http://www.usernomics.com/ergonomic-...essories5.html
        > >>
        > >> Both scripts work perfectly when there is one script on a page. However,
        > >> if
        > >> I place two on the page (one above the other), the second script will not
        > >> render. I get no PHP error messages - the script will just not render.[/color]
        > >
        > > Its cuz both scripts have a <body></body> It seems to render ok here
        > > in IE, in FF its all wierd, like the divs are overlapping. Probly in
        > > your browser, its stopping at the first </body>.
        > >
        > > --
        > > juglesh
        > >[/color]
        >
        > Thanks for the information juglesh. I am new to all of this. How would you
        > change that to make it work?[/color]

        You'll have to look at the scripts you are including. Without knowing
        exactly what youre working with, (is the main page yours? are you
        including the other scripts, or are you starting with one script, and
        adding the other, etc) What I would do, is make my own page.php. Then
        include the scripts you need. But, edit those scripts so they dont
        have the body tags. Your page will have the body tags. So your script
        will look like:

        <head>stuff</head>
        <body>
        include scriptone.php
        include scripttwo.php
        </body>

        Or, you could edit the closing body tag out of the first, and the
        opening body tag out of the second.

        Then youre going to need to look at your divs and figure out the
        positioning, relative/absolute, etc.

        hth
        --
        juglesh

        Comment

        • luke

          #5
          Re: Two PHP Scripts on same page?


          Without being able to see the PHP code it's difficult to pin-point what the
          problem may be (viewing the source of a page online just returns HTML, no
          PHP).

          Just a little brainstorm:

          - make sure any open braces '{' are matched with a closing brace '}'

          - make sure all '<?php' tags are matched with a closing '?>' tag

          - check if one of the scripts has a 'die();' command, if so, it could be
          terminating the page at that point

          Having 2 PHP scripts on the same page should cause no problems at all. So
          I'm thinking it's probably an overlapping tag of some sort.

          Luke




          "ergobob" <ergobob@soni c[REMOVE].net> wrote in message
          news:7arFe.5637 $p%3.31307@typh oon.sonic.net.. .[color=blue]
          > Hello,
          >
          > I have two small PHP scripts running on a test page at:
          > http://www.usernomics.com/ergonomic-...essories5.html
          >
          > Both scripts work perfectly when there is one script on a page. However,[/color]
          if[color=blue]
          > I place two on the page (one above the other), the second script will not
          > render. I get no PHP error messages - the script will just not render.
          >
          > I think the PHP Scripts are OK as they were automatically generated by RSS
          > Feed Burner and both do run separately.
          >
          > There may be an issue with having separate calls of some kind on the page[/color]
          or[color=blue]
          > my server might not be set right. I did a server test that I think shows
          > that it is OK but I am not sure. The results table is at
          > http://www.usernomics.com/ergonomic-...ries-test.html . The
          > only think I have in my htaccess file for PHP is: "AddType
          > application/x-httpd-php .htm .html" .
          >
          > I am new to PHP and was wondering if anyone can see why both scripts will
          > not run together?
          >
          > Thanks a lot,
          >
          > Bob
          >
          >[/color]


          Comment

          • ergobob

            #6
            Re: Two PHP Scripts on same page?

            Hi Guys,

            Thanks for the reply. I thought I would give you more information in the
            hopes that it will help.

            Both scripts are supposed to pull in 10 news articles. There is an ad at the
            very bottom of the news articles from RSS Feed Reader. The first script
            shows the 10 articles but the second script only shows the ad. It does not
            bring in the 10 articles.

            If I reverse the order of the feeds, it shows that both work but on the
            first one renders the 10 articles. Also, the PHP was automatically generated
            by RSS Feed Reader so I think they both work fine. It is the second of the
            sequence that is the problem.

            The PHP scripts are very similar but they bring in articles from two
            different feeds. The host is the same for both though.

            Below are the PHP scripts.

            Does this give you any ideas? Several people have looked at
            this with no solution.

            Thanks a lot,

            Bob

            ---


            <!-- RSS Feed Reader Usability In The News -->
            <div class="centeral l"><a
            href="http://www.usernomics. com/news/user-interface-design-news.html"
            title="Usernomi cs In The News">Usability In The News</a></div>
            <div class="centerme dium">Latest Headlines


            <div class="scroll">
            <?php
            include
            ("http://www.rssfeedread er.com/rss3/rss.php?url=htt p%3A%2F%2Ffeeds .feedburner.com %2FNewsErgonomi csUserInterface DesignComputerH umanInteraction hci&newpage=&ch ead=&atl=&desc= 1&auth=&dts=&wi dth=128&max=10& tlen=0&rnd=&bt= &bs=None&nmb=1& ntb=1&naf=1&nst =1&nwd=0&nht=0& dlen=100&bg=%23 FFFFFF&bc=&tc=B LACK&ts=8&tfont =Verdana,+Arial ,+Sans-serif&rf=".$HTT P_SERVER_VARS['SERVER_NAME'].$HTTP_SERVER_V ARS['PHP_SELF']."&phpout=1" );
            ?>
            </div>
            <div class="centerme dium"><a
            href="http://feeds.feedburne r.com/NewsErgonomicsU serInterfaceDes ignComputerHuma nInteractionhci "
            title="Usabilit y News Feed"><img src="images/site/rss.gif" alt="Usability In
            The News RSS Feed"></a></div>
            </div>
            <!-- /RSS Feed Reader Usability In The News -->



            <!-- /RSS Feed Reader Ergonomics In The News -->
            <div class="centeral l"><a
            href="http://www.usernomics. com/news/workplace-ergonomics-news.html"
            title="Ergonomi cs In The News">Ergonomic s In The News</a></div>
            <div class="centerme dium">Latest Headlines

            <div class="scroll">
            <?php
            include
            ("http://www.rssfeedread er.com/rss3/rss.php?url=htt p%3A%2F%2Ffeeds .feedburner.com %2FUsernomicsWo rkplaceErgonomi csSafetyBiometr ics&newpage=&ch ead=&atl=&desc= 1&auth=&dts=&wi dth=128&max=10& tlen=0&rnd=&bt= &bs=None&nmb=1& ntb=1&naf=1&nst =1&nwd=0&nht=0& dlen=100&bg=%23 FFFFFF&bc=&tc=B LACK&ts=8&tfont =Verdana,+Arial ,+Sans-serif&rf=".$HTT P_SERVER_VARS['SERVER_NAME'].$HTTP_SERVER_V ARS['PHP_SELF']."&phpout=1" );
            ?>

            </div>
            <div class="centerme dium"><a
            href="http://feeds.feedburne r.com/UsernomicsWorkp laceErgonomicsS afetyBiometrics "
            title="Ergonomi cs News Feed"><img src="images/site/rss.gif" alt="Ergonomics
            In The News RSS Feed"></a></div>
            </div>
            <!-- /RSS Feed Reader Ergonomics In The News -->

            </div>


            Comment

            • luke

              #7
              Re: Two PHP Scripts on same page?


              Odd :).

              I'm wondering whether the rssfeeder site's script is identifying your site
              once with the URL of the first include

              $HTTP_SERVER_VA RS['SERVER_NAME'].$HTTP_SERVER_V ARS['PHP_SELF']

              and is then refusing to serve you any more with the second include, as a
              security measure.

              Could be a good question to ask the rssfeeder site's owner.

              Luke



              "ergobob" <ergobob@soni c[REMOVE].net> wrote in message
              news:r7MFe.5774 $p%3.31809@typh oon.sonic.net.. .[color=blue]
              > Hi Guys,
              >
              > Thanks for the reply. I thought I would give you more information in the
              > hopes that it will help.
              >
              > Both scripts are supposed to pull in 10 news articles. There is an ad at[/color]
              the[color=blue]
              > very bottom of the news articles from RSS Feed Reader. The first script
              > shows the 10 articles but the second script only shows the ad. It does not
              > bring in the 10 articles.
              >
              > If I reverse the order of the feeds, it shows that both work but on the
              > first one renders the 10 articles. Also, the PHP was automatically[/color]
              generated[color=blue]
              > by RSS Feed Reader so I think they both work fine. It is the second of the
              > sequence that is the problem.
              >
              > The PHP scripts are very similar but they bring in articles from two
              > different feeds. The host is the same for both though.
              >
              > Below are the PHP scripts.
              >
              > Does this give you any ideas? Several people have looked at
              > this with no solution.
              >
              > Thanks a lot,
              >
              > Bob
              >
              > ---
              >
              >
              > <!-- RSS Feed Reader Usability In The News -->
              > <div class="centeral l"><a
              > href="http://www.usernomics. com/news/user-interface-design-news.html"
              > title="Usernomi cs In The News">Usability In The News</a></div>
              > <div class="centerme dium">Latest Headlines
              >
              >
              > <div class="scroll">
              > <?php
              > include
              >[/color]
              ("http://www.rssfeedread er.com/rss3/rss.php?url=htt p%3A%2F%2Ffeeds .feedburne
              r.com%2FNewsErg onomicsUserInte rfaceDesignComp uterHumanIntera ctionhci&newpag e
              =&chead=&atl=&d esc=1&auth=&dts =&width=128&max =10&tlen=0&rnd= &bt=&bs=None&nm b
              =1&ntb=1&naf=1& nst=1&nwd=0&nht =0&dlen=100&bg= %23FFFFFF&bc=&t c=BLACK&ts=8&tf o
              nt=Verdana,+Ari al,+Sans-serif&rf=".$HTT P_SERVER_VARS['SERVER_NAME'].$HTTP_SE
              RVER_VARS['PHP_SELF']."&phpout=1" );[color=blue]
              > ?>
              > </div>
              > <div class="centerme dium"><a
              >[/color]
              href="http://feeds.feedburne r.com/NewsErgonomicsU serInterfaceDes ignComputerH
              umanInteraction hci"[color=blue]
              > title="Usabilit y News Feed"><img src="images/site/rss.gif" alt="Usability[/color]
              In[color=blue]
              > The News RSS Feed"></a></div>
              > </div>
              > <!-- /RSS Feed Reader Usability In The News -->
              >
              >
              >
              > <!-- /RSS Feed Reader Ergonomics In The News -->
              > <div class="centeral l"><a
              > href="http://www.usernomics. com/news/workplace-ergonomics-news.html"
              > title="Ergonomi cs In The News">Ergonomic s In The News</a></div>
              > <div class="centerme dium">Latest Headlines
              >
              > <div class="scroll">
              > <?php
              > include
              >[/color]
              ("http://www.rssfeedread er.com/rss3/rss.php?url=htt p%3A%2F%2Ffeeds .feedburne
              r.com%2FUsernom icsWorkplaceErg onomicsSafetyBi ometrics&newpag e=&chead=&atl=& d
              esc=1&auth=&dts =&width=128&max =10&tlen=0&rnd= &bt=&bs=None&nm b=1&ntb=1&naf=1 &
              nst=1&nwd=0&nht =0&dlen=100&bg= %23FFFFFF&bc=&t c=BLACK&ts=8&tf ont=Verdana,+Ar i
              al,+Sans-serif&rf=".$HTT P_SERVER_VARS['SERVER_NAME'].$HTTP_SERVER_V ARS['PHP_
              SELF']."&phpout=1" );[color=blue]
              > ?>
              >
              > </div>
              > <div class="centerme dium"><a
              >[/color]
              href="http://feeds.feedburne r.com/UsernomicsWorkp laceErgonomicsS afetyBiometr
              ics"[color=blue]
              > title="Ergonomi cs News Feed"><img src="images/site/rss.gif"[/color]
              alt="Ergonomics[color=blue]
              > In The News RSS Feed"></a></div>
              > </div>
              > <!-- /RSS Feed Reader Ergonomics In The News -->
              >
              > </div>
              >
              >[/color]


              Comment

              • ergobob

                #8
                Re: Two PHP Scripts on same page?


                "luke" <lduncalfe@eml. nope> wrote in message
                news:f_TFe.4002 $PL5.374342@new s.xtra.co.nz...[color=blue]
                >
                > Odd :).
                >
                > I'm wondering whether the rssfeeder site's script is identifying your site
                > once with the URL of the first include
                >
                > $HTTP_SERVER_VA RS['SERVER_NAME'].$HTTP_SERVER_V ARS['PHP_SELF']
                >
                > and is then refusing to serve you any more with the second include, as a
                > security measure.
                >
                > Could be a good question to ask the rssfeeder site's owner.
                >
                > Luke
                >
                >
                >
                > "ergobob" <ergobob@soni c[REMOVE].net> wrote in message
                > news:r7MFe.5774 $p%3.31809@typh oon.sonic.net.. .[color=green]
                >> Hi Guys,
                >>
                >> Thanks for the reply. I thought I would give you more information in the
                >> hopes that it will help.
                >>
                >> Both scripts are supposed to pull in 10 news articles. There is an ad at[/color]
                > the[color=green]
                >> very bottom of the news articles from RSS Feed Reader. The first script
                >> shows the 10 articles but the second script only shows the ad. It does
                >> not
                >> bring in the 10 articles.
                >>
                >> If I reverse the order of the feeds, it shows that both work but on the
                >> first one renders the 10 articles. Also, the PHP was automatically[/color]
                > generated[color=green]
                >> by RSS Feed Reader so I think they both work fine. It is the second of
                >> the
                >> sequence that is the problem.
                >>
                >> The PHP scripts are very similar but they bring in articles from two
                >> different feeds. The host is the same for both though.
                >>
                >> Below are the PHP scripts.
                >>
                >> Does this give you any ideas? Several people have looked at
                >> this with no solution.
                >>
                >> Thanks a lot,
                >>[/color][/color]


                The answer to the problem is to put <?php unset($arnews); ?>
                before each include.

                Bob


                Comment

                Working...