Jump to content

warning and error message?


Nicholas16

Recommended Posts

this is the warning messages.

 

Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'death'@'localhost' (using password: YES) in /home/a3122898/public_html/class/class_db_mysql.php on line 42

 

FATAL ERROR: Could not connect to database on localhost (Access denied for user 'death'@'localhost' (using password: YES))

 

this is the coding for class_db_mysql.php

 

<?php
if(!defined('MONO_ON')) { exit; }

if (!extension_loaded('mysql')) {
   if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
       dl('php_mysql.dll');
   } else {
       dl('mysql.so');
   }
}

class database {
  var $host;
  var $user;
  var $pass;
  var $database;
  var $persistent=0;
  var $last_query;
  var $result;
  var $connection_id;
  var $num_queries=0;
  var $start_time;
  function configure($host, $user, $pass, $database, $persistent=0)
  {
    $this->host=$host;
    $this->user=$user;
    $this->pass=$pass;
    $this->database=$database;
    $this->persistent=$persistent;
    return 1; //Success.
  }
  function connect()
  {
    if(!$this->host) { $this->host="localhost"; }
    if(!$this->user) { $this->user="root"; }
    if($this->persistent)
    {
      $this->connection_id=mysql_pconnect($this->host, $this->user, $this->pass) or $this->connection_error();
    }
    else
    {
      $this->connection_id=mysql_connect($this->host, $this->user, $this->pass, 1) or $this->connection_error();
    }
    mysql_select_db($this->database, $this->connection_id);
    return $this->connection_id;
  }
  function disconnect()
  {
    if($this->connection_id) { mysql_close($this->connection_id); $this->connection_id=0; return 1; }
    else { return 0; }
  }
  function change_db($database)
  {
    mysql_select_db($database, $this->connection_id);
    $this->database=$database;
  }
  function query($query)
  {
    $this->last_query=$query;
    $this->num_queries++;
    $this->result=mysql_query($this->last_query, $this->connection_id) or $this->query_error();
    return $this->result;
  }
  function fetch_row($result=0)
  {
    if(!$result) { $result=$this->result; }
    return mysql_fetch_assoc($result);
  }
  function num_rows($result=0)
  {
    if(!$result) { $result=$this->result; }
    return mysql_num_rows($result);
  }
  function insert_id()
  {
    return mysql_insert_id($this->connection_id);
  }
  function connection_error()
  {
    die("<b>FATAL ERROR:</b> Could not connect to database on {$this->host} (".mysql_error().")");
  }
  function query_error()
  {
    die("<b>QUERY ERROR:</b> ".mysql_error()."<br />
    Query was {$this->last_query}");
  }
  function fetch_single($result=0)
  {
    if(!$result) { $result=$this->result; }
    return mysql_result($result, 0, 0);
  }
  function event_add($user, $event)
  {
    //event should be pre-escaped.
    $this->query("INSERT INTO `event` VALUES('', {$user}, '{$event}', unix_timestamp(), 0)");
    $this->query("INSERT INTO `event_log` VALUES('', {$user}, '{$event}', unix_timestamp())");
    $this->query("UPDATE `user` SET new_events=new_events+1 WHERE userid={$user}");
  }
  function mymicro()
  {
    $m=explode(" ", microtime());
    return $m[0]+$m[1];
  }
  function clock_start()
  {
    $this->start_time=$this->mymicro();
  }
  function clock_end()
  {
    $t=$this->mymicro();
    return round($t-$this->start_time, 4);
  }
  function clean_input($in)
  {
    $in=stripslashes($in);
    return str_replace(array("<",">",'"',"'","\n"), array("<",">",""","&#39;","<br />"), $in);
  }
  function clean_input_nohtml($in)
  {
    $in=stripslashes($in);
    return str_replace(array("'"), array("&#39;"), $in);
  }
  function clean_input_nonform($in)
  {
    return addslashes($in);
  }
  function easy_insert($table, $data)
  {
    $query="INSERT INTO `$table` (";
    $i=0;
    foreach($data as $k => $v)
    {
      $i++;
      if($i > 1) { $query.=", "; }
      $query.=$k;
    }
    $query.=") VALUES(";
    $i=0;
    foreach($data as $k => $v)
    {
      $i++;
      if($i > 1) { $query.=", "; }
      $query.="'".addslashes($v)."'";
    }
    $query.=")";
    return $this->query($query);
  }
  function make_integer($str, $positive=1)
  {
  $str = (string) $str;
  $ret = "";
  for($i=0;$i<strlen($str);$i++)
  {
    if((ord($str[$i]) > 47 && ord($str[$i]) < 58) or ($str[$i]=="-" && $positive == 0)) { $ret.=$str[$i]; }
  }
  if(strlen($ret) == 0) { return "0"; }
  return $ret;
  }
  function unhtmlize($text)
  {
    return str_replace("<br />","\n", $text);
  }  
  function escape($text)
  {
    return mysql_real_escape_string($text, $this->connection_id);
  }
  function affected_rows($conn = NULL)
  {
    return mysql_affected_rows($this->connection_id);
  }

}
?>

 

can anyone find out what the problem is please?

Link to comment
https://forums.phpfreaks.com/topic/166562-warning-and-error-message/
Share on other sites

if you mean the config.php file this is the coding i have

 

<?php
$_CONFIG = array(
'hostname' => 'localhost',
'username' => 'xxxxxxxx',
'password' => 'xxxxxxxxxx',
'database' => 'xxxxxxxxxx',
'persistent' => 0,
'driver' => 'mysql',
'code' => 'b7f6c53b10490603645ac9995d5c915c'
);
?>

 

or the class_db_mysql.php

 

<?php
if(!defined('MONO_ON')) { exit; }

if (!extension_loaded('mysql')) {
   if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
       dl('php_mysql.dll');
   } else {
       dl('mysql.so');
   }
}

class database {
  var $host;
  var $user;
  var $pass;
  var $database;
  var $persistent=0;
  var $last_query;
  var $result;
  var $connection_id;
  var $num_queries=0;
  var $start_time;
  function configure($host, $user, $pass, $database, $persistent=0)
  {
    $this->host=$host;
    $this->user=$user;
    $this->pass=$pass;
    $this->database=$database;
    $this->persistent=$persistent;
    return 1; //Success.
  }
  function connect()
  {
    if(!$this->host) { $this->host="localhost"; }
    if(!$this->user) { $this->user="root"; }
    if($this->persistent)
    {
      $this->connection_id=mysql_pconnect($this->host, $this->user, $this->pass) or $this->connection_error();
    }
    else
    {
      $this->connection_id=mysql_connect($this->host, $this->user, $this->pass, 1) or $this->connection_error();
    }
    mysql_select_db($this->database, $this->connection_id);
    return $this->connection_id;
  }
  function disconnect()
  {
    if($this->connection_id) { mysql_close($this->connection_id); $this->connection_id=0; return 1; }
    else { return 0; }
  }
  function change_db($database)
  {
    mysql_select_db($database, $this->connection_id);
    $this->database=$database;
  }
  function query($query)
  {
    $this->last_query=$query;
    $this->num_queries++;
    $this->result=mysql_query($this->last_query, $this->connection_id) or $this->query_error();
    return $this->result;
  }
  function fetch_row($result=0)
  {
    if(!$result) { $result=$this->result; }
    return mysql_fetch_assoc($result);
  }
  function num_rows($result=0)
  {
    if(!$result) { $result=$this->result; }
    return mysql_num_rows($result);
  }
  function insert_id()
  {
    return mysql_insert_id($this->connection_id);
  }
  function connection_error()
  {
    die("<b>FATAL ERROR:</b> Could not connect to database on {$this->host} (".mysql_error().")");
  }
  function query_error()
  {
    die("<b>QUERY ERROR:</b> ".mysql_error()."<br />
    Query was {$this->last_query}");
  }
  function fetch_single($result=0)
  {
    if(!$result) { $result=$this->result; }
    return mysql_result($result, 0, 0);
  }
  function event_add($user, $event)
  {
    //event should be pre-escaped.
    $this->query("INSERT INTO `event` VALUES('', {$user}, '{$event}', unix_timestamp(), 0)");
    $this->query("INSERT INTO `event_log` VALUES('', {$user}, '{$event}', unix_timestamp())");
    $this->query("UPDATE `user` SET new_events=new_events+1 WHERE userid={$user}");
  }
  function mymicro()
  {
    $m=explode(" ", microtime());
    return $m[0]+$m[1];
  }
  function clock_start()
  {
    $this->start_time=$this->mymicro();
  }
  function clock_end()
  {
    $t=$this->mymicro();
    return round($t-$this->start_time, 4);
  }
  function clean_input($in)
  {
    $in=stripslashes($in);
    return str_replace(array("<",">",'"',"'","\n"), array("<",">",""","&#39;","<br />"), $in);
  }
  function clean_input_nohtml($in)
  {
    $in=stripslashes($in);
    return str_replace(array("'"), array("&#39;"), $in);
  }
  function clean_input_nonform($in)
  {
    return addslashes($in);
  }
  function easy_insert($table, $data)
  {
    $query="INSERT INTO `$table` (";
    $i=0;
    foreach($data as $k => $v)
    {
      $i++;
      if($i > 1) { $query.=", "; }
      $query.=$k;
    }
    $query.=") VALUES(";
    $i=0;
    foreach($data as $k => $v)
    {
      $i++;
      if($i > 1) { $query.=", "; }
      $query.="'".addslashes($v)."'";
    }
    $query.=")";
    return $this->query($query);
  }
  function make_integer($str, $positive=1)
  {
  $str = (string) $str;
  $ret = "";
  for($i=0;$i<strlen($str);$i++)
  {
    if((ord($str[$i]) > 47 && ord($str[$i]) < 58) or ($str[$i]=="-" && $positive == 0)) { $ret.=$str[$i]; }
  }
  if(strlen($ret) == 0) { return "0"; }
  return $ret;
  }
  function unhtmlize($text)
  {
    return str_replace("<br />","\n", $text);
  }  
  function escape($text)
  {
    return mysql_real_escape_string($text, $this->connection_id);
  }
  function affected_rows($conn = NULL)
  {
    return mysql_affected_rows($this->connection_id);
  }

}
?>

 

i got it from the mccodes v2 file.

 

EDIT BY OBER: Removed username/pw.

if you mean the config.php file this is the coding i have

 

No, I mean the code where you actually use this class. Which by the way seeing as you didn't write it yourself, is a pretty crap database access class. Why bother? When there are better programmed objects built right into php. See pdo.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.