Umieściłem stronkę w Wamp Server i chciałem umieścić logowanie do stronki.
Podczas logowania wyskakują błędy :
Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'admin'@'localhost' (using password: YES) in C:\wamp\www\class.DB.php on line 12
Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in C:\wamp\www\class.DB.php on line 13
Warning: mysql_select_db(): supplied argument is not a valid MySQL-Link resource in C:\wamp\www\class.DB.php on line 14
Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in C:\wamp\www\class.DB.php on line 26
Warning: mysql_error(): supplied argument is not a valid MySQL-Link resource in C:\wamp\www\class.DB.php on line 47
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\wamp\www\class.DB.php on line 30
A o to plik class.DB
<?php
require_once('class.config.php');
class DB{
protected $db;
protected $query_result;
private static $instance;
private function __construct(){
$config = config::singleton();
$this->db = mysql_connect($config->host, $config->user, $config->pass);
mysql_query("SET NAMES uft8",$this->db);
mysql_select_db($config->db, $this->db);
}
public static function singleton() {
if (!isset(self::$instance)) {
$c = __CLASS__;
self::$instance = new $c();
}
return self::$instance;
}
public function send_query($query){
$this->query_result = mysql_query($query,$this->db);
}
public function getRow(){
if ( $row = mysql_fetch_array($this->query_result, MYSQL_ASSOC) ){
return $row;
}else{
return false;
}
}
public function rowCount(){
return mysql_num_rows($this->query_result);
}
public function getInsertedId(){
return mysql_insert_id($this->db);
}
public function isQueryError(){
if ($this->query_result === false){
return mysql_error($this->db);
}else{
return false;
}
}
public function change_db($db){
if(mysql_select_db($db)){
return true;
}else{
return mysql_error();
}
}
}
?>
W pliku class.config mam ustawiony login i hasło.
Może coś pominąłem?
Może ktoś wie w czym tkwi błąd??