Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: ERROR mysql_num_rows POMOCY!
Forum PHP.pl > Forum > PHP
Marecki669
Witam,
Mam problem ze skryptem aktywacji konta po przez email. Gdy podaje wartości czyli /activate.php?id=3&code=c6654769c83cda14c84270307a2e245d wyskakuje mi błąd:

SCREAM: Error suppression ignored for
( ! ) Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\wamp\www\activate.php on line 12
Zły ID lub Kod Aktywacyjny.

Oto plik activate.php
  1. <?php
  2. include 'include/funkcje.php';
  3.  
  4. $id = $_GET['id'];
  5. $code = $_GET['code'];
  6.  
  7. if ($id&&$code)
  8. {
  9.  
  10. $check = mysql_query("SELECT * FROM users WHERE user_id='$id' AND user_code_activation='$code'");
  11. $checknum = mysql_num_rows($check);
  12.  
  13. if ($checknum==1)
  14. {
  15.  
  16. $acti = mysql_query("UPDATE users SET user_activated='1' WHERE user_id='$id'");
  17. die("Użytkownik został aktywowany.");
  18.  
  19. }
  20. else
  21. die("Zły ID lub Kod Aktywacyjny.");
  22.  
  23.  
  24. }else
  25. die("Data missing!");
  26.  
  27. ?>
  28.  



Proszę o pomoc z góry dziękuję.
radziopoke
a czy przypadkiem funkcja mysql_query nie ma dwóch parametrów? Pierwsze jest zapytanie, a drugim powinna być zmienna odpowiedzialna za połączenie z daną bazą.
amii
Cytat z manula do wartości zwracanych z mysql_query:

Return Values

For SELECT, SHOW, DESCRIBE, EXPLAIN and other statements returning resultset, mysql_query() returns a resource on success, or FALSE on error.

For other type of SQL statements, INSERT, UPDATE, DELETE, DROP, etc, mysql_query() returns TRUE on success or FALSE on error.

The returned result resource should be passed to mysql_fetch_array(), and other functions for dealing with result tables, to access the returned data.

Use mysql_num_rows() to find out how many rows were returned for a SELECT statement or mysql_affected_rows() to find out how many rows were affected by a DELETE, INSERT, REPLACE, or UPDATE statement.

mysql_query() will also fail and return FALSE if the user does not have permission to access the table(s) referenced by the query.
Marecki669
Dziękuję bardzo radziopoke pomogło. Dziękuję smile.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-2025 Invision Power Services, Inc.