Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [MySQL][PHP]Problem z wartością num_rows
e-milnet
post
Post #1





Grupa: Zarejestrowani
Postów: 18
Pomógł: 0
Dołączył: 18.08.2011

Ostrzeżenie: (0%)
-----


W dwóch funkcjach rejestracyjnej i logującej wyskakuje mi błąd z num_rows.

-1 funkcja Notice: Trying to get property of non-object:
  1. function login($name_us, $password)
  2. {
  3. $connect = connect_bd();
  4.  
  5. $result = $connect->query("select * from users where name_user=".$name_us." and password = sha1('".$password."')");
  6.  
  7. if (!$result)
  8. {
  9. $errors[]='Logowanie nie powiodło się';
  10. }
  11.  
  12. if ($result->num_rows>0)
  13. {
  14. return true;
  15. }
  16. else
  17. {
  18. $errors[]='Logowanie nie powiodło się';
  19. }
  20. }

-2 funkcja Notice: Undefined property: mysqli::$num_rows:
  1. function register($name_user, $email, $password)
  2. {
  3.  
  4. $connect = connect_bd();
  5.  
  6. $result = $connect->query("select * from users where name_user='".$name_user."'");
  7.  
  8. if (!$result)
  9. {
  10. $errors[]='Wykonanie zapytania nie powiodło się.';
  11. }
  12.  
  13. if ($connect->num_rows>0)
  14. {
  15. $errors[]='Nazwa użytkownika zajęta - proszę wrócić i wybrać inną.';
  16. }
  17.  
  18. $result = $connect->query("insert into users values ('".$name_user."', sha1('".$password."'), '".$email."')");
  19.  
  20. if (!$result)
  21. {
  22. $errors[]='Rejestracja w bazie danych niemożliwa - proszę spróbować później.';
  23. }
  24.  
  25. if(empty($errors))
  26. {
  27. return true;
  28. }
  29. else
  30. {
  31. return $errors;
  32. }
  33.  
  34. }


Ten post edytował e-milnet 7.09.2011, 10:10:27
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 5.10.2025 - 08:26