Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Nie poprawne działanie skryptu..., Powinien działać a nie działa...
yarns
post
Post #1





Grupa: Zarejestrowani
Postów: 16
Pomógł: 0
Dołączył: 15.06.2005

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


Witam,

mam taki oto fragment kodu:

  1. <?php
  2.  
  3. function logIn($login, $password)
  4. {
  5. $sql = "select ID, ACTIVATION from users " .
  6.  "where NAME = '" . $login . "' AND PASS = '" . $password . "' limit 1";
  7.  
  8. if (!$result = @mysql_query($sql, $this->mySqlConnection))
  9. {
  10. echo "#" . mysql_errno() . ": " . mysql_error();
  11.  
  12. $this->log->addLog(0, 0, 'Class: user, Method: logIn(), SQL: ' . $sql);
  13.  
  14. return 0;
  15. }
  16. else 
  17. {
  18. if (mysql_num_rows($result))
  19. {
  20. $userId = mysql_fetch_row($result);
  21.  
  22. /* jeśli konto aktywowane, logujemy */
  23.  
  24. if ($userId[1])
  25. {
  26. $this->userId = $userId[0];
  27. $_SESSION['userId'] = $userId[0];
  28.  
  29. $this->genData();
  30.  
  31. $sql = "update users set LASTLOGIN = now() where id = '" . $userId[0] . "' limit 1";
  32. if (!@mysql_query($sql, $this->mySqlConnection))
  33. {
  34. echo "#" . mysql_errno() . ": " . mysql_error();
  35.  
  36. $this->log->addLog(0, 0, 'Class: user, Method: logIn(), SQL: ' . $sql);
  37. }
  38. $this->log->addLog(2, 2);
  39. return 1;
  40. }
  41. else 
  42. {
  43. $this->userId = $userId[0];
  44. $this->log->addLog(2, 0);
  45. return -1;
  46. }
  47. }
  48. else
  49. {
  50. $this->log->addLog(0, 0, 'Class: user, Method: logIn(), SQL: ' . $sql);
  51. return 0;
  52. }
  53. }
  54. }
  55.  
  56. ?>


I nie wiem czemu... ale przy wpisaniu porawnych wartości login i hasło wszystko jest ok... ale jak wpisze błedny login lub hasło dostaje błąd:
#1064: Something is wrong in your syntax obok 'test' AND PASS = 'zlehaslo' limit 1')' w linii 1
Jakieś podpowiedzi?

Pozdrawiam

Ten post edytował yarns 15.01.2006, 18:53:45
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: 25.08.2025 - 14:00