Resulta que no puedo conectarme a la Base de datos ya que me muestra el siguiente error
Código PHP:
Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user 'giova'@'localhost' (using password: NO) in /home/giova/public_html/miweb.com/core/db.php on line 4
Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in /home/giova/public_html/miweb.com/core/db.php on line 4
Código PHP:
<?php
function secure($string){
if(!is_array($string)){
return mysql_real_escape_string(strip_tags($string));
} else {
foreach($string as $key => $value){
if(!is_array($value)){
$string[$key] = mysql_real_escape_string($value);
} else {
foreach($value as $_key => $_value){
$string[$key][$_key] = mysql_real_escape_string(strip_tags($_value));
}
}
}
return $string;
}
}
function ordenar ($toOrderArray, $field, $inverse = false) {
$position = array();
$newRow = array();
foreach ($toOrderArray as $key => $row) {
$position[$key] = $row[$field];
$newRow[$key] = $row;
}
if ($inverse) {
arsort($position);
}
else {
asort($position);
}
$returnArray = array();
foreach ($position as $key => $pos) {
$returnArray[] = $newRow[$key];
}
return $returnArray;
}
abstract class DBAbstractModel {
private static $db_host = 'localhost';
private static $db_user = 'giova_test';
private static $db_pass = 'test25125';
protected $db_name = 'giova_test';
protected $query;
public $id;
public $rows = array();
public $rows2 = array();
public $rows3 = array();
public $etiquetas = array();
public $paginacion = array();
private $conn;
public $count;
public $count2;
public $mensaje = 'Hecho';
# Conectar a la base de datos
private function open_connection() {
$this->conn = new mysqli(self::$db_host, self::$db_user,
self::$db_pass, $this->db_name);
}
# Desconectar la base de datos
private function close_connection() {
$this->conn->close();
}
# Ejecutar un query simple del tipo INSERT, DELETE, UPDATE
protected function execute_single_query($id = 0) {
$this->open_connection();
$this->conn->set_charset("utf8");
$this->conn->query($this->query);
if($id == 1){
$this->id = $this->conn->insert_id;
}
$this->close_connection();
}
# Traer resultados de una consulta en un Array
protected function get_results_from_query($id = 0) {
$this->open_connection();
$result = $this->conn->query($this->query);
if($id == 0){
while ($this->rows[] = $result->fetch_assoc());
array_pop($this->rows);
} else {
while ($this->etiquetas[$id][] = $result->fetch_assoc());
array_pop($this->etiquetas[$id]);
}
$result->close();
$this->close_connection();
}
# Traer resultados de una consulta en un Array
protected function get_results_from_query_2() {
$this->open_connection();
$result = $this->conn->query($this->query);
while ($this->rows3[] = $result->fetch_assoc());
array_pop($this->rows3);
$result->close();
$this->close_connection();
}
# Contar Resultados
protected function count_query() {
$this->open_connection();
$result = $this->conn->query($this->query);
unset($this->rows2);
while ($this->rows2[] = $result->fetch_assoc());
$this->count = count($this->rows2) - 1;
unset($this->rows2);
$result->close();
$this->close_connection();
}
}
?>
Por favor necesito de su apoyo, ya que no sé por qué aparece ese error y no puedo conectarme a la BD.
Muchas gracias.