Funktionen

Einklappen
X
 
  • Filter
  • Zeit
  • Anzeigen
Alles löschen
neue Beiträge

  • Funktionen

    Wie war das nochmal mit den Functionen?

    in der index.php habe ich das
    PHP-Code:
    <?php
    cat
    ()
    while(
    $cat_row mysql_fetch_array($cat))// zeile 36
        
    {
    ?>
    in der db.inc.php habe ich das
    PHP-Code:
    function cat()
        {
        
    $cat mysql_query ("SELECT * FROM forum_categorie ORDER BY cat_auth");
        } 
    in der Version bekomme ich folgende Fehlermeldung:
    Parse error: parse error, unexpected T_WHILE in C:\wampp2036\htdocs\forum0.1\forum\index.php on line 36

    Mach ich bei cat() ein ; kommt diese Fehlermeldung:
    Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\wampp2036\htdocs\forum0.1\forum\index.php on line 36
    *winks*
    Gilbert
    ------------------------------------------------
    Hilfe für eine Vielzahl von Problemen!!!
    http://www.1st-rootserver.de/

  • #2
    PHP-Code:
    function cat()
        {
        
    $cat mysql_query ("SELECT * FROM forum_categorie ORDER BY cat_auth");
        } 
    und woher weiß dein Skript, was du in der funktion in $cat geschrieben hast ??

    noch return $cat und dann gleich so:
    PHP-Code:
    while($cat_row mysql_fetch_array(cat())) {


    gruss

    Kommentar


    • #3
      h das ; muss auf jeden fall hin, aber warum kann er mit sql statement nichts anfangen...hm.. gute frage..keine ahnung..ist zu warm
      ich bin Toxical, und werd es auch bleiben

      Kommentar


      • #4
        @fatal

        Wie jetzt Bahnhof???

        Jetzt kommt eine endlos schleidfe raus.!!!
        Fatal error: Maximum execution time of 30 seconds exceeded in C:\wampp2036\htdocs\forum0.1\inc\db.inc.php on line 7

        PHP-Code:
        while($cat_row = mysql_fetch_array(cat()))
        {
        ?>
        <tr>
        <td colspan="6">
        <table width="100%" border="0" bgcolor="#DFDFDF">
        <tr>
        <td><font face="Comic Sans MS" size="2"><?php echo"$cat_row[cat_name]";?></font></td>
        </tr>
        </table>
        </td>
        </tr>
        <?php
        $forum 
        mysql_query ("SELECT * FROM forum WHERE forum_cat='$cat_row[id]'");
        while(
        $forum_row mysql_fetch_array($forum))
        {
        ?>
        Un der untere teil geht garnicht!!!
        Zuletzt geändert von Wotan; 05.08.2002, 16:43.
        *winks*
        Gilbert
        ------------------------------------------------
        Hilfe für eine Vielzahl von Problemen!!!
        http://www.1st-rootserver.de/

        Kommentar


        • #5
          dann machs nochmal wie vorhin, schreib das cat(); davor.

          gruss

          Kommentar


          • #6
            Dann wieder die Fehlermeldung:
            Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\wampp2036\htdocs\forum0.1\forum\index.php on line 36
            *winks*
            Gilbert
            ------------------------------------------------
            Hilfe für eine Vielzahl von Problemen!!!
            http://www.1st-rootserver.de/

            Kommentar


            • #7
              probiers erstmal ohne die Funktion, ganz normal. Wenn das geht, ersetzt du das, was in der Funktion steht durch die Funktion.

              gruss

              Kommentar


              • #8
                *grmpf*

                Das hatte ich ja erst und nun wollte ich das in eine Function stellen damit ich den Kram nicht immer Tippen muß sondern per Function darauf zugreifen kann und dann kommen die fehlermeldunge.
                *winks*
                Gilbert
                ------------------------------------------------
                Hilfe für eine Vielzahl von Problemen!!!
                http://www.1st-rootserver.de/

                Kommentar


                • #9
                  PHP-Code:
                  <?php
                  function cat() {
                      
                  $cat mysql_query ("SELECT * FROM forum_categorie ORDER BY cat_auth");
                      return 
                  $cat// Rückgabewert ist sicher nicht das Schlechteste.
                  }

                  // ...

                  cat();

                  while(
                  $cat_row mysql_fetch_array($cat)) {
                     
                  // .... da gehts sicher noch irgendwie weiter, hoffentlich
                  }
                  ?>

                  Kommentar


                  • #10
                    du hattest hier auch ein ; vergessen, hast du das bemerkt ??
                    cat();
                    while($cat_row = mysql_fetch_array($cat))// zeile 36
                    {

                    gruss

                    Kommentar


                    • #11
                      Diesmal war meine hand schneller

                      gruss

                      Kommentar


                      • #12
                        Original geschrieben von hand
                        PHP-Code:
                        <?php
                        function cat() {
                            
                        $cat mysql_query ("SELECT * FROM forum_categorie ORDER BY cat_auth");
                            return 
                        $cat// Rückgabewert ist sicher nicht das Schlechteste.
                        }

                        // ...

                        cat();

                        while(
                        $cat_row mysql_fetch_array($cat)) {
                           
                        // .... da gehts sicher noch irgendwie weiter, hoffentlich
                        }
                        ?>
                        Da kommt die Fehlermeldung:
                        Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\wampp2036\htdocs\forum0.1\forum\index.php on line 40

                        hier mal das ganze script:
                        PHP-Code:
                        <?php
                        include_once("../inc/db_data.inc.php");
                        include_once(
                        "../inc/function.inc.php");
                        //include_once("../inc/db.inc.php");
                        function cat() {
                            
                        $cat mysql_query ("SELECT * FROM forum_categorie ORDER BY cat_auth");
                            return 
                        $cat// Rückgabewert ist sicher nicht das Schlechteste.
                        }
                        ?>
                        <html>
                        <head>
                        <meta http-equiv="Content-Language" content="de">
                        <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
                        <meta name="GENERATOR" content="PFE 32">
                        <meta http-equiv="pragma" content="no-cache">
                        <meta http-equiv="cache-control" content="no-cache">
                        <title>Forum by Webdesign - CCT</title>
                        </head>
                        <body>
                        <table width="100%" border="0">
                        <tr>
                            <td>
                        <?php
                        include("header/header_home.php");
                        ?>
                            </td>
                        </tr>
                        </table>
                        <table width="100%" border="1"cellpadding="0" cellspacing="0">
                        <tr>
                            <td width="5%" bgcolor="#DFDFDA">&nbsp;</td>
                            <td width="65%" bgcolor="#DFDFDA"><font face="Comic Sans MS" size="2">Forum</font></td>
                            <td width="5%" bgcolor="#DFDFDA"><center><font face="Comic Sans MS" size="1">Beiträge</font></center></td>
                            <td width="5%" bgcolor="#DFDFDA"><center><font face="Comic Sans MS" size="1">Themen</font></center></td>
                            <td width="10%" bgcolor="#DFDFDA"><center><font face="Comic Sans MS" size="1">Letzer Beitrag</font></center></td>
                            <td width="10%" bgcolor="#DFDFDA"><center><font face="Comic Sans MS" size="1">Moderator</font></center></td>
                        </tr>
                        <?php
                        cat
                        ();
                        while(
                        $cat_row mysql_fetch_array($cat))// Zile 40
                            
                        {
                        ?>
                        <tr>
                            <td colspan="6">
                            <table width="100%" border="0" bgcolor="#DFDFDF">
                            <tr>
                                <td><font face="Comic Sans MS" size="2"><?php echo"$cat_row[cat_name]";?></font></td>
                            </tr>
                            </table>
                            </td>
                        </tr>
                        <?php
                            $forum 
                        mysql_query ("SELECT * FROM forum WHERE forum_cat='$cat_row[id]'");
                            while(
                        $forum_row mysql_fetch_array($forum))
                                {
                        ?>
                        <tr>
                            <td width"5%" bgcolor="#DFDFDF">&nbsp;</td>
                            <td width"65%"><font face="Comic Sans MS" size="2"><?php echo"$forum_row[forum_name]";?><br></font><font face="Comic Sans MS" size="1"><?php echo"$forum_row[forum_title]";?></font></td>
                            <td width="5%"><font face="Comic Sans MS" size="1">Anzahl</font></td>
                            <td width="5%"><font face="Comic Sans MS" size="1">Anzahl</font></td>
                            <td width="10%"><font face="Comic Sans MS" size="1">Letzer Beitrag</font></td>
                            <td width="10%"><font face="Comic Sans MS" size="1">Moderator</font></td>
                        </tr>
                        <?php
                                
                        }
                            }
                        ?>
                        </table>
                        </body>
                        </html>
                        *winks*
                        Gilbert
                        ------------------------------------------------
                        Hilfe für eine Vielzahl von Problemen!!!
                        http://www.1st-rootserver.de/

                        Kommentar


                        • #13
                          @MortAlan (konnte ja nicht wissen, daß Wotan nochwas dazwischen rein postet)
                          Ob Du Dich da nicht irrst?
                          Zuletzt geändert von hand; 05.08.2002, 16:59.

                          Kommentar


                          • #14
                            PHP-Code:
                            <?php
                            include_once("../inc/db_data.inc.php");
                            include_once(
                            "../inc/function.inc.php");
                            //include_once("../inc/db.inc.php");
                            function cat() {
                                
                            $cat mysql_query ("SELECT * FROM forum_categorie ORDER BY cat_auth");
                                return 
                            $cat// Rückgabewert ist sicher nicht das Schlechteste.
                            }
                            ?>
                            <html>
                            <head>
                            <meta http-equiv="Content-Language" content="de">
                            <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
                            <meta name="GENERATOR" content="PFE 32">
                            <meta http-equiv="pragma" content="no-cache">
                            <meta http-equiv="cache-control" content="no-cache">
                            <title>Forum by Webdesign - CCT</title>
                            </head>
                            <body>
                            <table width="100%" border="0">
                            <tr>
                                <td>
                            <?php
                            include("header/header_home.php");
                            ?>
                                </td>
                            </tr>
                            </table>
                            <table width="100%" border="1"cellpadding="0" cellspacing="0">
                            <tr>
                                <td width="5%" bgcolor="#DFDFDA">&nbsp;</td>
                                <td width="65%" bgcolor="#DFDFDA"><font face="Comic Sans MS" size="2">Forum</font></td>
                                <td width="5%" bgcolor="#DFDFDA"><center><font face="Comic Sans MS" size="1">Beiträge</font></center></td>
                                <td width="5%" bgcolor="#DFDFDA"><center><font face="Comic Sans MS" size="1">Themen</font></center></td>
                                <td width="10%" bgcolor="#DFDFDA"><center><font face="Comic Sans MS" size="1">Letzer Beitrag</font></center></td>
                                <td width="10%" bgcolor="#DFDFDA"><center><font face="Comic Sans MS" size="1">Moderator</font></center></td>
                            </tr>
                            <?php
                            // cat();
                            $cat mysql_query ("SELECT * FROM forum_categorie ORDER BY cat_auth");
                            while(
                            $cat_row mysql_fetch_array($cat))// Zile 40
                                
                            {
                            ?>
                            <tr>
                                <td colspan="6">
                                <table width="100%" border="0" bgcolor="#DFDFDF">
                                <tr>
                                    <td><font face="Comic Sans MS" size="2"><?php echo"$cat_row[cat_name]";?></font></td>
                                </tr>
                                </table>
                                </td>
                            </tr>
                            <?php
                                $forum 
                            mysql_query ("SELECT * FROM forum WHERE forum_cat='$cat_row[id]'");
                                while(
                            $forum_row mysql_fetch_array($forum))
                                    {
                            ?>
                            <tr>
                                <td width"5%" bgcolor="#DFDFDF">&nbsp;</td>
                                <td width"65%"><font face="Comic Sans MS" size="2"><?php echo"$forum_row[forum_name]";?><br></font><font face="Comic Sans MS" size="1"><?php echo"$forum_row[forum_title]";?></font></td>
                                <td width="5%"><font face="Comic Sans MS" size="1">Anzahl</font></td>
                                <td width="5%"><font face="Comic Sans MS" size="1">Anzahl</font></td>
                                <td width="10%"><font face="Comic Sans MS" size="1">Letzer Beitrag</font></td>
                                <td width="10%"><font face="Comic Sans MS" size="1">Moderator</font></td>
                            </tr>
                            <?php
                                    
                            }
                                }
                            ?>
                            </table>
                            </body>
                            </html>
                            Und jetzt?

                            Kommentar


                            • #15
                              Das war mein erste Entwurf.
                              Jetzt wollte ich es über Functionen machen.
                              Ohne Function geht es.

                              Nur nicht mit der Funktion. *grmpf* Ich will nicht immer die ganze mysql_query`s tippen, ich will das als Function.
                              *winks*
                              Gilbert
                              ------------------------------------------------
                              Hilfe für eine Vielzahl von Problemen!!!
                              http://www.1st-rootserver.de/

                              Kommentar

                              Lädt...
                              X