Include

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

    Include

    How can I include another php file into a php file. In HTML you use <?php
    include test.php?>. But I want to include test.php somewhere in my php
    script. How can I make that work ??

    --
    RotterdamStuden ts
    -------------------------------
    Dulce est despirere loco
    (Horatius, "Oden" 4,12,28)



  • Jan Pieter Kunst

    #2
    Re: Include

    In article <c738uq$ovu$1@n ews.cistron.nl> ,
    "RotterdamStude nts" <N0SPAMnews@wil leboerm.cistron .nl> wrote:
    [color=blue]
    > How can I include another php file into a php file. In HTML you use <?php
    > include test.php?>. But I want to include test.php somewhere in my php
    > script. How can I make that work ??[/color]

    Just put

    include('test.p hp');

    at the point in your php file where you need to include test.php.

    JP

    --
    Sorry, <devnull@cauce. org> is een "spam trap".
    E-mail adres is <jpk"at"akamail .com>, waarbij "at" = @.

    Comment

    • RotterdamStudents

      #3
      Re: Include

      > > How can I include another php file into a php file. In HTML you use
      <?php[color=blue][color=green]
      > > include test.php?>. But I want to include test.php somewhere in my php
      > > script. How can I make that work ??[/color]
      >
      > Just put
      >
      > include('test.p hp');
      >
      > at the point in your php file where you need to include test.php.
      >
      > JP[/color]

      Thanks but this doesn't work. Below you see the script i want it in:

      <?php
      require "ind.inc.ph p";
      $ezine_db = ezine_connecte_ db();
      $datum = strftime("%d %m %Y", $datum);

      $str_requete = "SELECT fid,link FROM fotos ORDER BY fid ASC";

      $result_article s = mysql_query ($str_requete,$ ezine_db) or
      ezine_mysql_die ();

      print ('<table width=75%><font face=arial size=2>');

      while ($articleDb =mysql_fetch_ob ject($result_ar ticles))
      {
      print("
      <tr><font face='arial' size='3'><td><i mg
      src='pics/$articleDb->link.jpg' width=400 heihgt=300
      alt=$articleDb->link.jpg></td></tr>
      <tr><td>include ('test.php');</td></tr>
      ");
      }

      print ('</font>');

      ?>


      --
      RotterdamStuden ts
      -------------------------------
      Dulce est despirere loco
      (Horatius, "Oden" 4,12,28)


      Comment

      • Jan Pieter Kunst

        #4
        Re: Include

        In article <c73b2i$rdv$1@n ews.cistron.nl> ,
        "RotterdamStude nts" <N0SPAMnews@wil leboerm.cistron .nl> wrote:
        [color=blue]
        > print("
        > <tr><font face='arial' size='3'><td><i mg
        > src='pics/$articleDb->link.jpg' width=400 heihgt=300
        > alt=$articleDb->link.jpg></td></tr>
        > <tr><td>include ('test.php');</td></tr>
        > ");[/color]



        This doesn't work because the include() is in the argument of print(),
        so it is interpreted as a string. You could split it up like this:

        print("<tr><fon t face='arial' size='3'><td><i mg
        src='pics/$articleDb->link.jpg' width=400 heihgt=300
        alt=$articleDb->link.jpg></td></tr>
        <tr><td>");

        include('test.p hp');

        print('</td></tr>');

        JP

        --
        Sorry, <devnull@cauce. org> is een "spam trap".
        E-mail adres is <jpk"at"akamail .com>, waarbij "at" = @.

        Comment

        • kingofkolt

          #5
          Re: Include

          "RotterdamStude nts" <N0SPAMnews@wil leboerm.cistron .nl> wrote in message
          news:c73b2i$rdv $1@news.cistron .nl...[color=blue][color=green][color=darkred]
          > > > How can I include another php file into a php file. In HTML you use[/color][/color]
          > <?php[color=green][color=darkred]
          > > > include test.php?>. But I want to include test.php somewhere in my php
          > > > script. How can I make that work ??[/color]
          > >
          > > Just put
          > >
          > > include('test.p hp');
          > >
          > > at the point in your php file where you need to include test.php.
          > >
          > > JP[/color]
          >
          > Thanks but this doesn't work. Below you see the script i want it in:
          >
          > <?php
          > require "ind.inc.ph p";
          > $ezine_db = ezine_connecte_ db();
          > $datum = strftime("%d %m %Y", $datum);
          >
          > $str_requete = "SELECT fid,link FROM fotos ORDER BY fid ASC";
          >
          > $result_article s = mysql_query ($str_requete,$ ezine_db) or
          > ezine_mysql_die ();
          >
          > print ('<table width=75%><font face=arial size=2>');
          >
          > while ($articleDb =mysql_fetch_ob ject($result_ar ticles))
          > {
          > print("
          > <tr><font face='arial' size='3'><td><i mg
          > src='pics/$articleDb->link.jpg' width=400 heihgt=300
          > alt=$articleDb->link.jpg></td></tr>
          > <tr><td>include ('test.php');</td></tr>
          > ");
          > }
          >
          > print ('</font>');
          >
          > ?>
          >
          >
          > --
          > RotterdamStuden ts
          > -------------------------------
          > Dulce est despirere loco
          > (Horatius, "Oden" 4,12,28)
          >
          >[/color]

          probably the best solution is to change your code to this...

          while ($articleDb =mysql_fetch_ob ject($result_ar ticles))
          {
          print("<tr><fon t face='arial' size='3'><td><i mg
          src='pics/$articleDb->link.jpg' width=400 heihgt=300
          alt=$articleDb->link.jpg></td></tr><tr><td>");
          include('test.p hp');
          print ("</td></tr>");
          }

          .... supposing that test.php contains just HTML. i didnt test this to check
          for errors but im sure it would work. BTW you spelled "height" wrong in the
          height attribute of your image (you spelled it "heihgt")

          - JP


          Comment

          Working...