Haiopei: includes

hi ich hab da ein Problem mit includes:

bei einem Include-Befehl, wird automatisch der PHP-Bereich verlassen, und bei meinen includes möchte ich das Script aber direct weiterführen.....

PROBLEM: lasse ich am einde des includeten Scripts das "?>" weg, gibt es einen Fehler.....

Mache ich es nach dem Include wieder auf, ebenfalls fehler.......

was tun?

  1. Hallo Haiopei,

    Mache ich es nach dem Include wieder auf, ebenfalls fehler.......

    ich habe keine Ahnung, was du genau meinst, aber das include() muss natürlich im php-Bereich stehen und die Datei die du "includierst" (blödes Wort :-)) muss *afaik* "neutral" sein was das öffnen und schließen von php-Bereichen angeht.

    was tun?

    dein Script posten (zumindest auszugsweise)

    Grüße aus Nürnberg
    Tobias

    --
    Selfcode: sh:( fo:) ch:? rl:( br:< n4:& ie:% mo:| va:) de:] zu:) fl:( ss:| ls:[ js:|
    1. Ok hier mein Script erstmal ohne includes.......

      <?php
      $host = "localhost";
      $user = "web293";
      $pass = "network";
      $dbname = "usr_web293_1";
      $table = "gb";

      $dblink = mysql_connect($host,$user,$pass);
      if (!$dblink) {
      echo "keine Datenbankverbindung möglich...";
      }
      else
      {
      mysql_select_db($table, $dblink);
      $alledaten = mysql_query("select * from gb order by eintragsid DESC");
      ?>
      <html>
      <head>
      <style>
      A:link { text-decoration : none; font-family: Verdana,Arial; font-size:10 pt; color:gray;}
      A:Visited { text-decoration : none; font-family: Verdana,Arial; font-size:10 pt; color:gray;}
      A:Active { text-decoration : none; font-family: Verdana,Arial; font-size:10 pt; color:gray;}
      A:Hover { text-decoration : none; font-family: Verdana,Arial; font-size:10 pt; color:black;}
      </style>
      </head>
      <body gbcolor="#F7F4ED">
      <center>
      <a href="eintragen.php"><img src="eintrag.jpg" border="0"></a>
      <?php
      while($daten = mysql_fetch_array($alledaten)) {
      ?>
      <table border="2" style=Border-collapse:collapse bordercolor="#D3C1A9" width="80%">
      <tr height="10%">
      <th width="100%" align="left">Geschrieben von: <a href="mailto:<?php echo $daten["mail"]; ?>"><?php echo $daten["nick"]; ?></a> am: <?php echo $daten["datum"]; ?></th>
      </tr>
      <tr height="80%">
      <th width="100%" align="center"><?php echo $daten["nachricht"]; ?></th>
      </tr>
      <?php
      if ($daten["site"] != "0") {
      if ($daten["icq"] != "0") {
      ?>
      <tr height="10%">
      <?php
      if ($daten["site"] != "0") {
      ?>
      <th width="50%"><a href="<?php echo $daten["site"]; ?>">Page</a></th>
      <?php
      }
      if ($daten["icq"] != "0") {
      ?>
      <th width="50%"><?php echo $daten["icq"]; ?></th>
      <?php
      }
      ?>
      </tr>
      <?php
      }
      }
      ?>
      </table>
      <br><br>
      <?php
      }
      ?>
      <a href="eintragen.php" border="0"><img scr="eintrag.jpg"></a>
      </center>
      </body>
      </html>
      <?php
      mysql_close($dblink);
      }
      ?>

      Als nächstes mit Includes:

      Index.php

      <?php
      $host = "localhost";
      $user = "xxxxxx";
      $pass = "xxxxxxx";
      $dbname = "usr_web293_1";
      $table = "gb";

      $dblink = mysql_connect($host,$user,$pass);
      if (!$dblink) {
      echo "keine Datenbankverbindung möglich...";
      }
      else
      {
      include('eintrag.php');
      }
      ?>

      eintrag.php

      <?php
      mysql_select_db($table, $dblink);
      $alledaten = mysql_query("select * from ".$table."order by eintragsid DESC");
      include('head.php');
      while($daten = mysql_fetch_array($alledaten)) {
      include('kasten.php');
      }
      include('bottom.php');
      mysql_close($dblink);
      ?>

      head.php

      <html>
      <head>
      <style>
      A:link { text-decoration : none; font-family: Verdana,Arial; font-size:10 pt; color:gray;}
      A:Visited { text-decoration : none; font-family: Verdana,Arial; font-size:10 pt; color:gray;}
      A:Active { text-decoration : none; font-family: Verdana,Arial; font-size:10 pt; color:gray;}
      A:Hover { text-decoration : none; font-family: Verdana,Arial; font-size:10 pt; color:black;}
      </style>
      </head>
      <body gbcolor="#F7F4ED">
      <center>
      <a href="eintragen.php"><img src="eintrag.jpg" border="0"></a>

      kasten.php

      <table border="2" style=Border-collapse:collapse bordercolor="#D3C1A9" width="80%">
      <tr height="10%">
      <th width="100%" align="left">Geschrieben von: <a href="mailto:<?php echo $daten["mail"]; ?>"><?php echo $daten["nick"]; ?></a> am: <?php echo $daten["datum"]; ?></th>
      </tr>
      <tr height="80%">
      <th width="100%" align="center"><?php echo $daten["nachricht"]; ?></th>
      </tr>
      <?php
      if ($daten["site"] != "0") {
      if ($daten["icq"] != "0") {
      include('tabelleunten.php');
      }
      }
      ?>
      </table>
      <br><br>

      tabelleunten.php

      <tr height="10%">
      <?php
      if ($daten["site"] != "0") {
      ?>
      <th width="50%"><a href="<?php echo $daten["site"]; ?>">Page</a></th>
      <?php
      }
      if ($daten["icq"] != "0") {
      ?>
      <th width="50%"><?php echo $daten["icq"]; ?></th>
      <?php
      }
      ?>
      </tr>

      bottom.php

      <a href="eintragen.php" border="0"><img scr="eintrag.jpg"></a>
      </center>
      </body>
      </html>

      So das wart jetzt sehr übersichtlich....sorry

      Danke für die schnelle Hilfe
      Haiopei

      1. Hallo Haiopei,

        Ok hier mein Script erstmal ohne includes.......
        [...]

        enthält das das gleiche wie die anderen Dateien zusammen?

        Ich sehe sonst nichts, was falsch ist - welche Fehlermeldung bekommst du denn? Außerdem kann man die Sachen durchaus in eine Datei schreiben - mehrere Dateien sind imho nicht nötig.

        $alledaten = mysql_query("select * from ".$table."order by eintragsid DESC");

        vor "order by" gehört noch ein Leerzeichen (du solltest dir die Querys immer ausgeben lassen um zu sehen, was wirklich an mysql_query() weitergegeben wird)

        <html>

        da fehlt ein doctype

        <style>

        hier fehlt ein type="..."

        A:link { [...] font-size:10 pt; [...]}

        zwischen Wert und Einheit darf kein Leerzeichen stehen.

        <body gbcolor="#F7F4ED">

        was soll gbcolor="" sein? Das gibt es nicht.

        <center>

        *pfui* dafür gibt es css.

        <a href="eintragen.php"><img src="eintrag.jpg" border="0"></a>

        da fehlt ein alt (außerdem gibt es border="" in html4.01 strict nicht mehr)

        <table border="2" style=Border-collapse:collapse bordercolor="#D3C1A9" width="80%">

        das was hinter style= steht gehört in Anführungszeichen.

        if ($daten["site"] != "0") {
        if ($daten["icq"] != "0") {

        warum nicht if($daten['site']!=0&&$daten['icq']!=0){...?

        }
        }

        du solltest deinen Quelltext einrücken, dann wird das ganze etwas übersichtlicher.

        Grüße aus Nürnberg
        Tobias

        --
        Selfcode: sh:( fo:) ch:? rl:( br:< n4:& ie:% mo:| va:) de:] zu:) fl:( ss:| ls:[ js:|
        1. tja... sehr geholfen hat mir das leider mit meinem eigentlichen problem net.....

          der Fehler, der rauskommt ist:

          Parse error: parse error in /home/www/web293/html/gb/eintrag.php on line 5

          cya

          1. Hallo Haiopei,

            Parse error: parse error in /home/www/web293/html/gb/eintrag.php on line 5

            ehrlichgesagt, habe ich keine Ahnung, warum es nicht funktioniert (möglicherweise funkt ja die head.php dazwischen?) - ich kann dir nur raten das ganze nicht auf so viele Dateien aufzuspliten, das ist imho unnötig.

            Grüße aus Nürnberg
            Tobias

            --
            Selfcode: sh:( fo:) ch:? rl:( br:< n4:& ie:% mo:| va:) de:] zu:) fl:( ss:| ls:[ js:|
      2. Als nächstes mit Includes:

        Index.php

        <?php
        $host = "localhost";
        $user = "xxxxxx";
        $pass = "xxxxxxx";
        $dbname = "usr_web293_1";
        $table = "gb";

        $dblink = mysql_connect($host,$user,$pass);
        if (!$dblink) {
        echo "keine Datenbankverbindung möglich...";
        }
        else
        {
        include('eintrag.php');
        }
        ?>

        eintrag.php

        <?php
        mysql_select_db($table, $dblink);
        $alledaten = mysql_query("select * from ".$table."order by eintragsid DESC");
        include('head.php');
        while($daten = mysql_fetch_array($alledaten)) {
        include('kasten.php');
        }
        include('bottom.php');
        mysql_close($dblink);
        ?>

        Vom Hauptscript "Index.php" her ist ja "<?php " noch offen, wenn Du nach eintrag.php springst. Lass in eintrag.php alle <?php und ?> weg. (Natürlich nicht nur das am Ende ... ) ;-)

        Gruß aus Petershagen

        1. Hallo stefan,

          Vom Hauptscript "Index.php" her ist ja "<?php " noch offen, wenn Du nach eintrag.php springst.

          nein, das stimmt schon so (ich mach das auch so)

          Lass in eintrag.php alle <?php und ?> weg. (Natürlich nicht nur das am Ende ... ) ;-)

          nein, dann wird der php-Code nicht mehr ausgeführt.

          Grüße aus Nürnberg
          Tobias

          --
          Selfcode: sh:( fo:) ch:? rl:( br:< n4:& ie:% mo:| va:) de:] zu:) fl:( ss:| ls:[ js:|