Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Błąd w kodzie (OOP)
-h0h-
post
Post #1





Goście







Co zrobiłem źle w tym kodzie ?
  1. <?php
  2. class sLogin{
  3. var $dbConnection;
  4. function dbConnect_mysql($dbConnection){
  5. $dbConnection = explode(&#092;".\", $dbConnection);
  6. mysql_connect($this->$dbConnection[0], $dbConnection[1], $dbConnection[2]);
  7. mysql_select_db($this->$dbConnection[3]);
  8.  }
  9.  }
  10. class sQuery{
  11. var $sql; 
  12.  function DOsQuery($m_query){ 
  13.  if (isset($m_query)) {
  14.  $this->sql = $m_query;
  15.  mysql_query($this->sql); 
  16.  }
  17.  } 
  18.  }
  19.  
  20.  
  21. class sResult{
  22. function return_result(){
  23. $polacz = new sLogin;
  24. $polacz->dbConnect_mysql(&#092;"localhost.root.krasnal.php\");
  25. $zapytanie = new sQuery;
  26. $result = $zapytanie->DOsQuery(&#092;"SELECT * FROM TABELA\");
  27. while ($line = mysql_fetch_array($result)){
  28. echo $line[pole];
  29. }
  30. }
  31.  }
  32. $test = new sResult;
  33. $test->return_result();
  34. ?>

Wyświtla mi:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in c:\usr\apache\httpd\html\site\db.php on line 27
Nie wybrano żadnej bazy danych
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
tiraeth
post
Post #2





Grupa: Przyjaciele php.pl
Postów: 1 789
Pomógł: 41
Dołączył: 30.10.2003
Skąd: Wrocław

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


  1. <?php
  2. // ........
  3. class sResult{
  4. function return_result(){
  5. $polacz = new sLogin;
  6. $polacz->dbConnect_mysql(&#092;"localhost.root.krasnal.php\");
  7. $zapytanie = new sQuery;
  8. $result = $zapytanie->DOsQuery(&#092;"SELECT * FROM TABELA\");
  9. while ($line = mysql_fetch_array($result)){
  10. echo &#092;"$line[pole]\";
  11. }
  12. }
  13. }
  14. // ........
  15. ?>


po co wykonujesz funkcję z klasy w klasie (IMG:http://forum.php.pl/style_emoticons/default/questionmark.gif)

polecam przeglądnąć pliki phpBB tam jest ładnie wszystko zrobione (IMG:http://forum.php.pl/style_emoticons/default/smile.gif)
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: 6.10.2025 - 12:26