php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #5986 Combination of msql() and msql_connect() causes lost connections.
Submitted: 2000-08-05 19:04 UTC Modified: 2001-11-29 16:30 UTC
From: pete at byways dot org Assigned:
Status: Closed Package: mSQL related
PHP Version: 4.0.1 OS: RedHat Linux 6.2
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: pete at byways dot org
New email:
PHP Version: OS:

 

 [2000-08-05 19:04 UTC] pete at byways dot org
The following script causes unexpected errors:

Function test ()
{
  $conn1 = msql_connect();
  msql_select_db("nsbo", $conn1);
  
  $Res = msql_query("SELECT * FROM State", $conn1);
  echo msql_NumRows($Res)." rows in State<br>";
  
  msql_close($conn1);
}

test();

$Res = msql("nsbo", "SELECT * FROM Member");
echo msql_NumRows($Res)." rows in Member<br>";  
$Res = msql("library", "SELECT * FROM Publication");
echo msql_NumRows($Res)." rows in Publication<br>";  

The output from PHP is this:

60 rows in State
713 rows in Member

Warning: 1 is not a valid mSQL-Link resource in /disk2/websites/NSBO/test/test_db.html on line 18

Warning: Supplied argument is not a valid mSQL result resource in /disk2/websites/NSBO/test/test_db.html on line 19
rows in Publication

I am using mSQL 2.0.11, PHP 4.0.1, and Apache 3.0.12.  My PHP configuration is:

./configure --with-apxs=/usr/sbin/apxs --with-gettext=no --with-msql --with-pgsql --without-mysql --enable-track-vars=yes --with-pdflib=/usr/local --with-zlib --with-jpeg-dir=/usr --with-tiff-dir=/usr --with-session=/tmp --enable-trans-sid


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-08-10 02:02 UTC] thies@php.net
fixed in CVS (patch by nick@loman.net)

 [2000-08-10 04:25 UTC] pete at byways dot org
I get the same errors after patching php_msql.c and re-running the script I provided.
 [2000-08-11 04:49 UTC] pete at byways dot org
I believe that the problem is caused by the msql_globals.default_link value being set to an mSQL database link that has been closed by _close_msql_link in php_msql.c.  Ideally, when a database link is closed, if it's the default link, then reset the default link to -1.  I'm not sure how to do that in the code.  I can get the script to work if I add this line to the _close_msql_link function:

msql_globals.default_link = -1;

However, I'm sure this is a less than adequate method, since we don't want to reset it all the time.

 [2001-11-25 07:41 UTC] mfischer@php.net
Can you test if this has changed with the latest RC?

http://www.php.net/~zeev/php-4.1.0RC3.tar.gz

Feedback.
 [2001-11-29 15:54 UTC] pete at byways dot org
I've confirmed this to be fixed as of PHP 4.0.6, Apache 1.3.20, mSQL 2.0.11.  The script provided also works in PHP 4.1.0RC3.




 [2001-11-29 15:55 UTC] derick@php.net
Whooohoo! it' fixed.

closing.
 [2001-11-29 16:30 UTC] mfischer@php.net
Hey, I wanted to close it X-)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 08:01:28 2024 UTC