Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

UserMaster

[Resolvido] Erro ao conectar MYSQL

Recommended Posts

Alguém me ajude por favor, não consigo acessar uma página, apareçe o seguinte erro:

 

" Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'parado_help'@'localhost' (using password: YES) in /home/parado/public_html/helpdesk/common/mysql.class.php on line 51

 

Fatal error: Call to undefined function: error() in /home/parado/public_html/helpdesk/common/mysql.class.php on line 52 "

 

 

Código-Fonte do arquivo mysql.class.php

 

################################################################################

######

 

 

<?php

/**

* file:	database.class.php

* 

* 	This file contains the mysql database class.

* 

/***************************************************************************

*  This program is free software; you can redistribute it and/or

*  modify it under the terms of the GNU General Public

*  License as published by the Free Software Foundation; either

*  version 2.1 of the License, or (at your option) any later version.

*

*  This program is distributed in the hope that it will be useful,

*  but WITHOUT ANY WARRANTY; without even the implied warranty of

*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU

*  General Public License for more details.

*

*  You should have received a copy of the GNU General Public

*  License along with This program; if not, write to:

*	Free Software Foundation, Inc.

*	59 Temple Place

*	Suite 330

*	Boston, MA  02111-1307  USA

*

* Copyright 2005 One or Zero

* info@oneorzero.com

* [url="http://www.oneorzero.com"]http://www.oneorzero.com[/url]

* Developers: OneOrZero Team / Contributors: OneOrZero Community

****************************************************************************/ 



class MySQL {

	var $db_host;

	var $db_user=;

	var $db_pwd=;

	var $db_name;

	var $queries = 0;

	var $connections = 0;

	var $link;



	function set($db_host, $db_user, $db_pwd, $db_name)

	{

		$this->db_host = $db_host;

		$this->db_user = $db_user;

		$this->db_pwd = $db_pwd;

		$this->db_name = $db_name;

	} 



	function connect()

	{ 

		// connect to mysql

		$this->link = mysql_connect($this->db_host, $this->db_user, $this->db_pwd)

		or die("Could not connect to mysql server: " . error()); 

		// connect to the database

		mysql_select_db($this->db_name, $this->link)

		or die("Database: database not found"); 

	   $this->connections++;

		// return $db_link for other functions

		//return $link;

	} 



	function query($sql)

	{ 

		//echo $sql . "<br>";

		if (!isset($this->link)) {

			$this->connect();

		}

		$result = mysql_query($sql, $this->link)

		or die("Invalid query: " . mysql_error()); 

		// used for other functions

		$this->queries++;

		return $result;

	} 



	function fetch_array($result)

	{ 

		// create an array called $row

		$row = mysql_fetch_array($result); 

		// return the array $row or false if none found

		return $row;

	} 



//	function fetch_row($result)

//	{ 

//		// create an array called $row

//		$row = mysql_fetch_row($result); 

//		// return the array $row or false if none found

//		return $row;

//	} 



	function num_rows($result)

	{ 

		// determine row count

		$num_rows = mysql_num_rows($result); 

		// return the row count or false if none foune

		return $num_rows;

	} 



	function insert_id()

	{ 

		// connect to the database

		//$link = $this->connect(); 

		// Get the ID generated from the previous INSERT operation

		$last_id = mysql_insert_id($this->link); 

		// return last ID

		return $last_id;

	} 



	function num_fields($result)

	{

		$result = mysql_num_fields($result);

		return $result;

	} 



//	function field_name($result, $index)

//	{ 

//		// query with the return of $result

//		$result = mysql_field_name($result, $index);

//		return $result;

//	} 

//

//	function tablename($result, $index)

//	{ 

//		// query with the return of $result

//		$result = mysql_tablename($result, $index);

//		return $result;

//	} 

//

//	function list_tables($dbase)

//	{

//		$result = mysql_list_tables($dbase);

//		return $result;

//	} 

} 



?>

 

Contato: Moacir -> m.petry9@gmail.com

Compartilhar este post


Link para o post
Compartilhar em outros sites

Access denied for user 'parado_help'@'localhost' (using password: YES)

 

Usuário e/ou senha incorretos, além da função errada que não é

error();
e sim
mysql_error();

Compartilhar este post


Link para o post
Compartilhar em outros sites

Se eu declaro

 

var $mysql_error;

 

e

 

 

or die("Could not connect to mysql server: " . mysql_error());

 

Aparece esse erro:

 

"

Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'parado_help'@'localhost' (using password: YES) in /home/parado/public_html/helpdesk/common/mysql.class.php on line 52

Could not connect to mysql server: Access denied for user 'parado_help'@'localhost' (using password: YES) "

 

O que eu posso fazer?

Compartilhar este post


Link para o post
Compartilhar em outros sites

Como o Alaerte disse anteriormente, o usuário parado_help ou a senha de acesso ao banco de dados está errado.

O erro não tem a ver com a declaração $mysql_error, que alias não está sendo utilizada.

Compartilhar este post


Link para o post
Compartilhar em outros sites

Além do mais, não é preciso declarar variável para

mysql_error();
pois esta é um função automática do mysql, basta adiciona-la ai final das querys como or die e pronto.

Compartilhar este post


Link para o post
Compartilhar em outros sites

E ae Pessoal, bom para quem estava acompanhando o erro aqui, finalmente achei o erro, é o seguinte:

O erro estava nas permissões do usuário , portanto quando entrei no CPANEL dessa página, fui em Base de Dados MySql e fui nesse usuário que estava dando o erro, quando vi as permissões que tinham e não estavam nenhuma marcada, as marquei e mas não salvou, nesse caso tive que entrar em contato com o meu servidor, e logo após eles darem permissões para este usuário funcionou normalmente.

Valeu pessoal, alguma dúvida entre em contato.

Moacir - moacir@negocianti.com

Negocianti - www.negocianti.com.br

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.