Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:3760 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 23609 invoked from network); 6 Aug 2003 09:52:58 -0000 Received: from unknown (HELO jawa.at) (213.229.17.146) by pb1.pair.com with SMTP; 6 Aug 2003 09:52:58 -0000 Received: from dings.jawa.at (dings.jawa.at [192.168.200.60]) by jawa.at (8.12.8p1/8.12.8) with ESMTP id h769qrXe093609 for ; Wed, 6 Aug 2003 11:52:53 +0200 (CEST) (envelope-from mbretter@jawa.at) Date: Wed, 6 Aug 2003 11:52:56 +0200 (=?ISO-8859-15?Q?Westeurop=E4ische_Normalzeit?=) To: internals@lists.php.net Message-ID: X-X-Sender: mbretter@files.jawa.at MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by amavisd-milter (http://amavis.org/) X-Spam-Status: No, hits=-11.4 required=5.0 tests=AWL,USER_AGENT_PINE autolearn=ham version=2.53 X-Spam-Checker-Version: SpamAssassin 2.53 (1.174.2.15-2003-03-30-exp) Subject: MySQL Problem retrieving errno, when connect fails + solution From: mbretter@jawa.at (Michael Bretterklieber) Hi, There is a problem in the MySQL extension when trying to get the errno, if the connection failed, if a prior mysql_connect() call already succeeded: mysql_connect('host', 'user', 'pw'); mysql_connect('host2', 'user2', 'pw2'); echo mysql_errno(); echo mysql_error(); Assuming the first call succeeds, but the second fails, then mysql_errno() just returns 0, but it shouldn't. That's because mysql_errno() uses the default_link for getting the errno in this case. There are two possible solutions: 1. set the default_link to -1 before makeing a new connection 2. change mysql_errno, with something like: ... snip ... case 1: if (zend_get_parameters_ex(1, &mysql_link)==FAILURE) { if (MySG(connect_errno)!=0){ RETURN_LONG(MySG(connect_errno)); } else { RETURN_FALSE; } } id = -1; break; ... I think 1. would be the better solution because 2. is only a workaround, or not? thanx, bye, -- ------------------------------- ---------------------------------- Michael Bretterklieber - http://www.bretterklieber.com JAWA Management Software GmbH - http://www.jawa.at Tel: ++43-(0)316-403274-12 - GSM: ++43-(0)676-84 03 15 712 ------------------------------- ---------------------------------- "...the number of UNIX installations has grown to 10, with more expected..." - Dennis Ritchie and Ken Thompson, June 1972