Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [phpAdsNew] konflikt w kodzie :/
Forum PHP.pl > Forum > Gotowe rozwiązania
kiecol
Było juz trochę tematów związanych z phpAdsNew, ale tematu na mój problem nie było

Mam skrypt filmów z allegro winksmiley.jpg

i po wklejeniu kody wyświetlania wywala mi błędy

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /srv/www/htdocs/web1/html/pages/list.php on line 23
Nie ma żadnych rekordów w tej kategorii.

kod z list.php
  1. <?php
  2.  
  3. if(isset($_GET['typ'])) {
  4. $typ = '`typ` = ' . (int) $_GET['typ'];
  5. }else{
  6. $typ = "((`typ` >= 1 and `typ` <= 4) or (typ = '15') or (typ = '16') or (typ = '17'))";
  7. }
  8.  
  9. //$typ = (isset($_GET['typ']) ? '`typ` = ' . (int) $_GET['typ'] : '((`typ` >= 1 and `typ` <= 4) or (typ = '15'))');
  10. $cat = (isset($_GET['cat']) ? ' and `category` = ' . (int) $_GET['cat'] : '');
  11. $order = '';
  12. if ($_GET['top'] == 1)
  13. {
  14. $order = ' order by `ocena` desc';
  15. }
  16. elseif ($_GET['last'] == 1)
  17. {
  18. $order = ' order by `added` desc';
  19. }
  20.  
  21. $res = mysql_query('select * from `stuff` where ' . $typ . $cat);
  22. // ilosć trafień
  23. $hits = mysql_num_rows($res);
  24.  
  25. $res = mysql_query('select * from `stuff` where ' . $typ . $cat . $order . ' order by added desc limit ' . ((int) $_GET['currentpage'] * 10) . ', ' . ((int) $_GET['currentpage'] * 10 + 10));
  26.  
  27. if ($hits == 0)
  28. {
  29. echo 'Nie ma żadnych rekordów w tej kategorii.';
  30. }
  31. else
  32. {
  33. while ($row = mysql_fetch_assoc($res))
  34.  
  35. {
  36. if($row['added']>0)
  37. $date = sprintf('<img src="ikonki/dodano.jpg"> Dodano: %s godzina %s<br />', date('Y.m.d', $row['added']), date('H:i:s', $row['added']));
  38. else
  39. $date = (string) '';
  40. $comments_count = (int) 0;
  41. $query = sprintf("SELECT COUNT(*) AS CommentsCount FROM komentarze WHERE stuff='%d'", $row['id']);
  42. $comments = mysql_query($query);
  43. if($comments) {
  44. $record = mysql_fetch_assoc($comments);
  45. $comments_count = $record['CommentsCount'];
  46. mysql_free_result($comments);
  47. }
  48. if($row['miniaturka']!='') { 
  49. $image = sprintf('<img src="%s" alt="%s" class="icon" align="right" width="160px" height="120px" border="2" style="border: 1px solid #A20000;"/>', $row['miniaturka'], $row['title']);
  50. } else {
  51. $image = '';
  52. }
  53. if(isset($categories[$row['category']]))
  54. $cat = sprintf("%s: ", $categories[$row['category']]);
  55. else
  56. $cat = (string) '';
  57. printf('<table width="461" bgcolor="#F3F3F3" style="margin-bottom:12px; font-family:verdana; font-size:12px;"><tr><td style="text-align:left; clear:both; padding:0 4px;">%s <strong>%s</strong><a href="index.php?page=display&id=%d" class="stufflink" style="font-weight:bold;"><h3>%s</h3></a><br /><br />%s<img src="ikonki/wykres.jpg"> Ocena: %d<br /><img src="ikonki/wykres.gif"> Wyswietlen: %d<br /><img src="ikonki/trabka.gif"> Komentarzy: %d<br /><img src="ikonki/info.gif"> Zasugerował: %s</td></tr></table>',
  58. $image,
  59. $cat, $row['id'], $row['tytul'],
  60. $date,
  61.  
  62.  
  63.  
  64.  
  65. $row['ocena'], $row['counter'],
  66. $comments_count, $row['login']);
  67. }
  68. }
  69.  
  70. echo '<div style="text-align: center">';
  71.  
  72. /********* NUMEROWANIE *********/
  73.  
  74. $temp = min((int) $_GET['currentpage'] + 5, ceil((float) $hits / 9.0));
  75.  
  76. for ($i = max((int) $_GET['currentpage'] - 4, 0); $i < $temp; $i++)
  77. {
  78.  print("<a href="index.php?page=list&currentpage=" . $i . "&cat=" . $_GET['cat'] . "">" . ($i+1) . "</a>");
  79.  if($i == ($temp - 1)) {
  80. print("<a href="index.php?page=list&currentpage=" . ($temp - 1) . "&cat=" . $_GET['cat'] . ""></a>");
  81.  }
  82. }
  83. /*******************************/
  84.  
  85. echo '</div>';
  86. ?>



Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /srv/www/htdocs/web1/html/index.php on line 148

Zarejestrowanych:
Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /srv/www/htdocs/web1/html/index.php on line 153

z index.php wycinek kodu, błędy są kolejno w 3 i 8 linij.
  1. <p><b>Wszystkich Filmików:<?php
  2. $res = mysql_query('select count(*) from `stuff` where `typ` <= 4 and `typ` >= 1');
  3. $row = mysql_fetch_assoc($res);
  4. echo $row['count(*)'];
  5. ?></p>
  6. <p>Zarejestrowanych: <?php
  7. $res = mysql_query('select count(*) from `fbw_useradmin`');
  8. $row = mysql_fetch_assoc($res);
  9. echo $row['count(*)'];
  10. ?></p>
  11. <p><b>Wszystkich kategori:<?php
  12. echo count($categories);
  13. ?></b></p>


Za pomoc w rozwiązaniu problemu byłbym wdzięczny.
starach
Sprawdź czy się łączysz z bazą poprawnie.
Czy zostaje ustanowione połączenie z bazą danych.
walnij mysql_connect() or die('No i nie ma połączenia');
Jak ci się nie wyświetli napis j.w. to oznacza że zapewne wprowadziłeś niepoprawne dane do łączenia się bazą danych.

Swoją drogą .... lol ale śmietnik w tym kodzie.... ale jeśli to allegro robiło to się nie dziwie tongue.gif
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-2024 Invision Power Services, Inc.