Witam zacząłem pisać własną klase, ale mam błędy:
! ) Warning
: mysql_query() expects parameter 2 to be resource
, null given in C
:\wamp\www\gra\
class.php on line
47 Call Stack
# Time Memory Function Location
1 0.0006 670512 {main}( ) ..\index.php:0
2 0.0052 725288 user->add( ) ..\index.php:6
3 0.0054 726152 mysql->query( ) ..\class.php:97
( ! ) Warning
: mysql_close() expects parameter 1 to be resource
, null given in C
:\wamp\www\gra\
class.php on line
62 Call Stack
# Time Memory Function Location
1 0.0057 716504 mysql->__destruct( ) ..\class.php:0
Kod PHP to:
{
private $host='localhost';
private $name='root';
private $pas='';
private $db='game';
private $handler;
public function connect(){
or
die('Błąd podczas łączenia z bazą danych.'); or
die('Błąd podczas łączenia z bazą danych.'); }
public function set($host,$name,$pas,$db){
$this->host = $host;
$this->name = $name;
$this->pas = $pas;
$this->db = $db;
}
public function query($query){
return $return;
}
public function query_num($query){
$result = mysq_query($query,$this->handler);
}
public function query_fetch($query){
}
public function __destruct(){
}
}
{
private $id;
public function setid($id){
$this->id=$id;
}
public function getid(){
return $this->id;
}
public function add($username,$password,$mail){
$code="";
for($l=1; $l<=24; $l++){
switch($a){
case 0:
$code .= chr
(rand(30
,39
)); break;
case 1:
$code .= chr
(rand(65
,90
)); break;
case 2:
$code .= chr
(rand(97
,122
)); break;
}
}
$this->query("INSERT INTO user ('user','password','mail','date','last','activate') VALUES ('$username','$password','$mail','$data','$time',$code)");
}
}
Proszę o pomoc!