mam pewną klase, która łaczy mi się z bazą danych i ma pobierać dane z niej.
klasy.php
<?php /** * @author Weogrim * @copyright 2009 * Klasa do obsługi MySQL */ class db { private $db_host = 'localhost'; private $db_name = 'klasy'; private $db_user = 'root'; private $db_pass = ''; public $errors = 0; public $queries = 0; public $result; private $connection; public $time = 0; public FUNCTION __construct() { $this->connection = @mysql_connect($this->db_host, $this->db_user, $this->db_pass) OR die('Brak połączenia z serwerem MySQL. <br>Błąd: '.mysql_error()); IF (!$this->connection) { $this->errors++; }else{ $db = @mysql_select_db($this->db_name, $this->connection) OR die('Nie mogę połączyć się z bazą danych. <br>Błąd: '.mysql_error()); } } public FUNCTION close() { mysql_close($this->connection); } public FUNCTION query($query) { $start = microtime(true); $this->result = @mysql_query($query); IF(!$this->result){ $this->errors++; RETURN false; }else{ $this->queries++; $this->time += microtime(true) - $start; RETURN true; } } public FUNCTION fetch_array($result) { $array = mysql_fetch_array(mysql_query($result)); IF(!$array) { RETURN false; $this->errors++; }else{ RETURN $array; $this->queries++; } } public FUNCTION rows($result) { $rows = mysql_num_rows(mysql_query($result)); IF(!$rows) { RETURN false; $this->errors++; }else{ $this->queries++; RETURN $rows; } } } ?>
index.php
<?php require_once "klasy.php"; $db = new db(); #$gryonline = $db->fetch_array("SELECT * FROM gryonline"); $result = ("SELECT * FROM gryonline"); while($row = $db->fetch_array($result)) { } ?>
z pobraniem jednego wpisu nie mam problemu, problem zaczyna się gdy chcę pobrać np wszystkie wpisy,,,