Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: supplied argument is not a valid MySQL result resource in /daten/www/sam001/testuje/list.php
Forum PHP.pl > Forum > Bazy danych > MySQL
sam001
Warning: mysql_numrows(): supplied argument is not a valid MySQL result resource in /daten/www/sam001/testuje/list.php on line 16

Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in /daten/www/sam001/testuje/list.php on line 40

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /daten/www/sam001/testuje/list.php on line 82

Podać jeszcze jakieś informacje? MySQL - 4.0.26. Dziękuję za jakiekolwiek porady i informacje. smile.gif
Kod
<?php include("theader.php"); ?>

<?php

   if ($letter) {

      $sql = "select tipid, title, date, rating from tips where title like '$letter%' and status = 'L' ";

   } else {

      $sql = "select tipid, title, date, rating from tips where catid = $catid and status = 'L' ";

   }

   $result = mysql_query($sql ,$db);
   $numrows = mysql_numrows($result);

   $lastpage = false;

   if ($pagenum == 0) {
      $startrow = 0;
   } else {
      $startrow = 25 * $pagenum;
   }

   if ($numrows < $startrow + 25) {
      $endrow = $numrows;
      $lastpage = true;
   }

   if ($letter) {

      $sql = "select tipid, title, date, rating from tips where title like '$letter%' and status = 'L' limit $startrow,25";
      $pagetitle = "Tips starting in the letter '$letter'";

   } else {

      $sql = "select * from categories where catid = $catid";
      $result = mysql_query($sql ,$db);
      $row = mysql_fetch_row($result);
      $pagetitle = $row[1];

      $sql = "select tipid, title, date, rating from tips where catid = $catid and status = 'L' limit $startrow,25";

   }

?>


    <TD align="left" valign="top" bgcolor="#DEDDDC">
      <table width="100%" border="0" cellspacing="5" cellpadding="5">
        <tr>
          <td valign="top">
            <TABLE width=100% cellpadding=5 cellspacing=0 border=0>

              <tr><td width=500 align=center>

                 <table cellpadding=1 cellspacing=1 border=0><tr><td bgcolor=#000000 width=500 height=20 valign=center align=center>
                    <table cellpadding=0 cellspacing=0 border=0><tr><td bgcolor=#cccccc width=498 height=18 valign=center align=left>
                       <font face="Arial, Helvetica, sans-serif" size="3"><b><?php printf($pagetitle); ?></b></font>
                     </td></tr></table>
                 </td></tr></table>

              </td></tr>

              <TR>
                <TD valign=top>

                  <table cellspacing=0 cellpadding=2 border=0>
                     <tr>
                        <th width=300 bgcolor=#bbbbbb align=center><FONT face=arial size=2>Tip</font></th>
                        <th width=85 bgcolor=#bbbbbb align=center><FONT face=arial size=2>Date Added</font></th>
                        <th width=75 bgcolor=#bbbbbb align=center><FONT face=arial size=2>Rating</font></th>
                     </tr>

                     <?php

                        $rowcolor = 1;

                        $result = mysql_query($sql ,$db);

                        if ($myrow = mysql_fetch_array($result)) {

                           do {

                              if ($rowcolor == 1) {
                                 $rowcolorhex = "#ffffff";
                                 $rowcolor = 0;
                              } else {
                                 $rowcolorhex = "#dddddd";
                                 $rowcolor = 1;
                              }


                              printf("<tr>");
                              printf("<td width=300 bgcolor=%s align=center><FONT face=arial size=2><a href=tip.php?tipid=%s>%s</a></font></td>", $rowcolorhex, $myrow["tipid"], $myrow["title"]);
                              printf("<td width=80 bgcolor=%s align=center><FONT face=arial size=2>%s</font></td>", $rowcolorhex, $myrow["date"]);
                              printf("<td width=75 bgcolor=%s><table bgcolor=%s border=0 cellspacing=0 cellpadding=0><tr>", $rowcolorhex, $rowcolorhex);

                              $onstars = round($myrow["rating"]);
                              $offstars = 5 - $onstars;

                              for ($i = 1; $i <= $onstars; $i++) {
                                 printf("<td width=15 bgcolor=%s align=center valign=center><FONT face=arial size=2><img src=images/staron2.gif></font></td>", $rowcolorhex);
                              }

                              for ($f = 1; $f <= $offstars; $f++) {
                                 printf("<td width=15 bgcolor=%s align=center valign=center><FONT face=arial size=2><img src=images/staroff2.gif></font></td>", $rowcolorhex);
                              }

                              printf("</tr></table></td>");
                              printf("</tr>");
                           } while ($myrow = mysql_fetch_array($result));

                        }

                        printf("<tr>");
                        if ($startrow > 0) {
                           printf("<td align=left><FONT face=arial size=2><a href=category.php?pagenum=%s&searchingred=%s&catid=%s&letter=%s>Previous Page</a></font></td>", $pagenum-1, $searchingred, $catid, $letter);
                        } else {
                           printf("<td> </td>");
                        }
                        printf("<td> </td>");
                        if ($lastpage == false) {
                           printf("<td align=left><FONT face=arial size=2><a href=category.php?pagenum=%s&searchingred=%s&catid=%s&letter=%s>Next Page</a></font></td>", $pagenum+1, $searchingred, $catid, $letter);
                        } else {
                           printf("<td> </td>");
                        }
                        printf("</tr>");

                     ?>

                </TD>
              </TR>

            </TABLE>

          </td>
        </tr>
      </table>
    </TD>

<?php include("tfooter.php"); ?>
siemakuba
1. czy w zmiennej $db ($result = mysql_query($sql ,$db);) masz poprawny identyfikator połączenia? Poprawny == utworzony przez funkcję mysql_connect()?

2. zrób echo mysql_error(); zaraz op mysql_query i sprawdź co ci powie

3. stawiam na date jako nazwa pola w bazie. Jest to chyba słowo zastrzeżone, więc powinieneś podawać je ujęte w 'backticki' --> ` (pod tyldą na klawiaturze):
  1. <?php
  2. $sql = "select tipid, title, `date`, rating from tips where title like '$letter%' and status = 'L' ";
  3. ?>


pozdr.
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.