Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [MSSQL][PHP] błąd w pobieraniu danych, Dawniej: zmiana typu zmiennej
matyskiewicz
post
Post #1





Grupa: Zarejestrowani
Postów: 184
Pomógł: 3
Dołączył: 6.10.2006
Skąd: Poznań

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


Podczas rozwiązywania problemu, udało mi się ustalić iż zmienia sie typ zmiennej
Dlaczego tak się dzieje i jak mogę zwrócić int?

  1. public function checkURL()
  2. {
  3. $this -> url = isset($_GET['page']) ? $_GET['page'] : Null;
  4. $this -> resultURL = NULL;
  5.  
  6. $db = NewADOConnection($this -> db());
  7. $db -> debug = true;
  8. $db -> SetFetchMode(ADODB_FETCH_ASSOC);
  9. $this -> checkURL = $db -> GetArray('SELECT id, url FROM section WHERE status > 0');
  10. $db -> Close();
  11.  
  12. for ($i=0; $i < sizeof($this -> checkURL); $i++)
  13. {
  14. #jezeli istnieje zwraca true
  15. if (strstr($this -> checkURL[$i]['url'], $this -> url))
  16. $this -> urlID = $this -> checkURL[$i]['id'];
  17. }
  18.  
  19. #NAJCIEKAWSZE =====================================================
  20.  
  21. echo'typ0: '.gettype($this -> urlID); //string
  22.  
  23. $this -> goodURL = settype($this -> urlID, "integer");
  24. echo'typ1: '.gettype($this -> goodURL); //bool
  25. return $this -> urlID;
  26.  
  27. }
  28.  
  29. public function dataFromStaticpage()
  30. {
  31. $this -> goodURL = settype($this -> checkURL(), "integer");
  32. echo'typ2: '.gettype($this -> goodURL); //bool
  33.  
  34. if($this -> goodURL !== NULL)
  35. {
  36.  
  37. $db = NewADOConnection($this -> db());
  38. $db -> debug = true;
  39. $db -> SetFetchMode(ADODB_FETCH_ASSOC);
  40. $resulturl = $db -> GetArray('SELECT * FROM section WHERE id = '.$this -> goodURL);
  41. $db -> Close();
  42.  
  43. echo '<pre>';
  44. print_r($resulturl);
  45. echo '</pre>';
  46. }
  47. else
  48. {
  49. echo 'brak strony';
  50. }
  51. }


  1. typ0: string
  2. typ1: boolean
  3. typ2: boolean


Ten post edytował matyskiewicz 7.04.2010, 12:48:32
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: 22.08.2025 - 19:56