Problem beim Filtern

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

  • Problem beim Filtern

    PHP-Code:
    <?php
      
    echo "<br>
            <div id='content'>"
    ;
      if (!isset(
    $download)) {
        
    $download 0;
      }
      if(
    $_SESSION['logon'] == '1')
        {
          
    $query_anzahl "SELECT * FROM downloads WHERE aktiv='1' AND update='1';";
          
    $result_anzahl mysql_query($query_anzahl) OR die(mysql_error());
          
    $anzahl mysql_num_rows($result_anzahl);
          
    $navigation ='';
          
    $next_page $download+5;
          
    $prev_page $download-5;
          if (
    $prev_page >= 0)
            {
              
    $navigation "<a href=\"index.php?action=downloads&download=$prev_page\">Vorherige Seite</a>\n";
            }
          if (
    $next_page $anzahl)
            {
              
    $navigation $navigation"   &nbsp;&nbsp;<a href=\"index.php?action=downloads&download=$next_page\">N&auml;chste Seite</a>\n";
            }

          
    $sql "SELECT * FROM downloads WHERE aktiv='1' AND update='1' LIMIT $download, 5;";
          
    $result mysql_query($sql) OR die(mysql_error());
          
    $row mysql_fetch_assoc($result);

        }
      else
        {
          
    $query_anzahl "SELECT * FROM downloads WHERE aktiv='1' AND update='0';";
          
    $result_anzahl mysql_query($query_anzahl);
          
    $anzahl mysql_num_rows($result_anzahl);
          
    $navigation ='';
          
    $next_page $download+5;
          
    $prev_page $download-5;

          if (
    $prev_page >= 0)
            {
              
    $navigation "<a href=\"index.php?action=downloads&download=$prev_page\">Vorherige Seite</a>\n";
            }
          if (
    $next_page $anzahl)
            {
              
    $navigation $navigation"   &nbsp;&nbsp;<a href=\"index.php?action=downloads&download=$next_page\">N&auml;chste Seite</a>\n";
            }

          
    $sql "SELECT * FROM downloads WHERE aktiv='1' AND update='0' LIMIT $download, 5;";
          
    $result mysql_query($sql) OR die(mysql_error());
          
    $row mysql_fetch_assoc($result);
        }
      echo 
    "</div>";
    ?>
    ich bekomme diesen Fehler:

    Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\apachefriends\xampp\htdocs\downloads.php on line 33
    You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'update='0' LIMIT 0, 5' at line 1

    jedoch wird in Zeile 33 die Anzahl ermittelt!!!

    was stimmt hier nicht?

  • #2
    das semikolon hat in deinen abfragen nichts verloren
    Ich denke, also bin ich. - Einige sind trotzdem...

    Kommentar


    • #3
      bisher haben die Semikolons nicht geschadet

      aber ich habe das Script noch mal vereinfacht, wenn das wieder geht, kann ich es wieder auftrennen:

      PHP-Code:
      <?php
        
      echo "<br>
              <div id='content'>"
      ;
        if (!isset(
      $download)) {
          
      $download 0;
        }
        
      $ja=1;
        
      $nein=0;
        
      $query_anzahl "SELECT * FROM downloads WHERE aktiv='$ja' AND update='$nein'";
        
      $result_anzahl mysql_query($query_anzahl);
        
      $anzahl mysql_num_rows($result_anzahl);  //Zeile 11
        
      $navigation ='';
        
      $next_page $download+5;
        
      $prev_page $download-5;
        if (
      $prev_page >= 0)
          {
            
      $navigation 
      "<a href=\"index.php?action=downloads&download=$prev_page\">Vorherige Seite</a>\n";
          }
        if (
      $next_page $anzahl)
          {
            
      $navigation $navigation
      "   &nbsp;&nbsp;<a href=\"index.php?action=downloads&download=$next_page\">N&auml;chste Seite</a>\n";
          }
        echo 
      "</div>";
      ?>
      der Fehler ist immer noch der selbe:

      Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\apachefriends\xampp\htdocs\downloads.php on line 11

      in meiner Referenzliste wie auch in meinem Blog gehen diese Zeilen, nur da habe ich nie etwas filtern müssen
      Zuletzt geändert von DannyL; 18.08.2004, 09:40.

      Kommentar


      • #4
        1. alle zeilen umbrechen, ich hab keine lust nach rechts scrollen zu müssen

        2.
        PHP-Code:
        $result_anzahl mysql_query($query_anzahl) or 
        die(
        mysql_error().'<hr />'.$query_anzahl); 
        3. ausgabe?
        Ich denke, also bin ich. - Einige sind trotzdem...

        Kommentar


        • #5
          update ist ein reserviertes Wort in mysql
          http://dev.mysql.com/doc/mysql/de/Reserved_words.html

          probiere `update`=...

          Kommentar


          • #6
            @oppi

            das wars, daran denke ich nicht immer *schäm*

            danke

            Kommentar

            Lädt...
            X