php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #695 mysql_error can't fetch the error afte the database connection is closed
Submitted: 1998-08-25 22:06 UTC Modified: 1998-09-02 13:33 UTC
From: mlemos at acm dot org Assigned:
Status: Closed Package: MySQL related
PHP Version: 3.0.3 OS: Any
Private report: No CVE-ID: None
 [1998-08-25 22:06 UTC] mlemos at acm dot org
If for some reason you want to fetch the error of a failed operation
but you close the connection before fetching the error mysql_error says
that that the connection link is invalid.

The following script shows that provided that the example user xpto is not
authorized to access the database mysql.

BTW, the error message says user @localhost is not authorized.  Shouldn't
it say user xpto@localhost is not authorized?

<?
	if(($link=mysql_pconnect("localhost","xpto","")))
	{
		if(($select=mysql_select_db("mysql"))==0)
			echo mysql_error();
		mysql_close($link);
	}
	echo mysql_error();
?>

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [1998-09-02 13:33 UTC] zeev
That's correct, and is the intended and planned behavior.

About the error message, it's coming from the MySQL server,
and some versions had buggy response strings.
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 03:01:26 2019 UTC