php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #429 mysql_connect/pconnect fail but mysql_errno is zero
Submitted: 1998-06-03 03:23 UTC Modified: 1998-06-03 17:27 UTC
From: marclang at cs dot washington dot edu Assigned:
Status: Closed Package: MySQL related
PHP Version: 3.0 Release Candidate 5 OS: UNIX/Linux
Private report: No CVE-ID: None
 [1998-06-03 03:23 UTC] marclang at cs dot washington dot edu
<HTML><HEAD><TITLE>Testing connection</TITLE></HEAD><BODY>
<?php
  $host = "localhost";  $user = "bogus";  $pw   = "foo";

  // error_reporting(1); /* Turn of "failed connect" warning */
  $conn = mysql_connect($host, $user, $pw);

  if ($conn || mysql_errno()) {
    echo "Failed connect to '$host' as user '$user' using pword '$pw'<br>\n";
  } else { 
    echo "Connected to host '$host'<br>\n";
  }

  echo "MySQL status: (".  mysql_errno().": '".mysql_error()."')<BR>";

?>
</BODY></HTML>


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [1998-06-03 17:27 UTC] zeev
Unfortunately, the documentation for mysql_errno() has
nothing to do with the way it really works.  The truth is
mysql_errno() accepts a MySQL link handle as an argument
(or uses the last open link as a default).
For that reason, mysql_errno()
is actually pretty useless, since most mysql_errno()
error levels report about connection problems, but until
a connection is actually made, there's no MySQL link handle
at all.

mysql_(p)connect() still display errors as they occur.
There's currently no real way to determine what error
occured when trying to connect to a MySQL server.
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Mon Jun 24 23:01:25 2019 UTC