Ostatnio mało bywałem na forum, ponieważ min. tworzyłem
[usunąłem linka] alek.
Ale nie w tym problem.
Stworzyłem klasę do obsługi bazy danych mysql.
<?php
class sql {
private $link;
private $result;
public $rows;
public function __construct {
$this -> $sql_host = 'localhost'; // Adres serwera bazy danych
$this -> $sql_name = 'forum'; // Nazwa bazy danych
$this -> $sql_user = 'root'; // Nazwa usera
$this -> $sql_password = ''; // Hasło
$this -> $sql_port = '3306'; // Port
$this -> link = mysql_connect($this -> $sql_host, $this -> $sql_user, $this -> $sql_password); }
}
public function __destruct () {
}
}
public function query($query) {
}
public function fetch_row() {
return 1;
}
}
}
?>
I nie działa.
Cały kod wygląda tak.
<?php
class sql {
private $link;
private $result;
public $rows;
public function __construct {
$this -> $sql_host = 'localhost'; // Adres serwera bazy danych
$this -> $sql_name = 'forum'; // Nazwa bazy danych
$this -> $sql_user = 'root'; // Nazwa usera
$this -> $sql_password = ''; // Hasło
$this -> $sql_port = '3306'; // Port
$this -> link = mysql_connect($this -> $sql_host, $this -> $sql_user, $this -> $sql_password); }
}
public function __destruct () {
}
}
public function query($query) {
}
public function fetch_row() {
return 1;
}
}
}
$sql = new sql;
$sql -> $query('SELECT username FROM users');
while($sql -> fetch_row()){
echo '<li>'.$sql -> rows
[0].'</li>'; }
?>
Co jest źle?