php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #729 mysql_connect reuses connection ids
Submitted: 1998-09-09 02:02 UTC Modified: 2001-02-10 12:27 UTC
From: walton at nordicdms dot com Assigned:
Status: Closed Package: Feature/Change Request
PHP Version: 3.0.3 OS: FreeBSD 2.2.6
Private report: No CVE-ID: None
 [1998-09-09 02:02 UTC] walton at nordicdms dot com
This can cause unpleasant problems when using a library function that cleans up after itself.

The script:

<?
  function some_reuseable_function() {
    // Pretend this function was included from another file
    $conn2 = mysql_connect('host', 'uid', 'pwd');
    echo "Function connection is: $conn2<br>\n";
    mysql_close($conn2);
  }

$conn1 = mysql_connect('host', 'uid', 'pwd');
echo "Main connection is: $conn1<br>\n";
some_reuseable_function();
mysql_close($conn1);
?>

The output:

Main connection is: 1
Function connection is: 1

Warning: 1 is not a MySQL link index in test.php3 on line 12


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-02-10 12:27 UTC] jimw@php.net
i'm pretty sure this was fixed in 4.0.
 [2022-12-08 12:51 UTC] git@php.net
Automatic comment on behalf of saundefined
Revision: https://github.com/php/web-php/commit/e8fde3b8cb5e4ca51013d035612b989d0eaa43ee
Log: Fix PHP 8.2.0 date
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu May 02 16:01:29 2024 UTC