php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #5756 Invalid sybase connections appearing
Submitted: 2000-07-24 13:00 UTC Modified: 2000-10-15 07:26 UTC
From: dclark at opsi dot co dot za Assigned: lyric (profile)
Status: Closed Package: Sybase-ct (ctlib) related
PHP Version: 4.0 Latest CVS (24/07/2000) OS: Linux
Private report: No CVE-ID: None
 [2000-07-24 13:00 UTC] dclark at opsi dot co dot za
 The following code produces some odd behaviour with respect to sybase connections.

 for ($i=0,$i<10,$i++) {
1.   $link = sybase_connect("x","x","x");
2.   echo "Link ID = $link -- ";
3.   sybase_select_db("x");
4.   $result = sybase_query("select ...");
5.   echo "Result ID = $result";
6.   $row = sybase_fetch_row($row);
7.   echo "query result = $row[0]";
8.   echo "------------- <br>";
 }

This code gives me the following output:
Link ID = Resource id#1 -- Result ID = Resource id#2 
query result = x
------------- 
Link ID = Resource id#1 --
Warning 1 is not a valid Sybase-Link resource in line 3
Warning 1 is not a valid Sybase-Link resource in line 4
Result ID =
Warning Supplied argument is not a valid Sybase result resource in line 6
query result = 
--------------
The above pattern repeats itself with the Link ID now Resource id#3 and Result ID = Resource id#4, etc

Removing Lines 6 and 7 gives :
Link ID = Resource id#1 -- Result ID = Resource id#2 
Link ID = Resource id#1 -- Result ID = Resource id#3 
Link ID = Resource id#4 -- Result ID = Resource id#5 
Link ID = Resource id#4 -- Result ID = Resource id#6 
Link ID = Resource id#7 -- Result ID = Resource id#8 
Link ID = Resource id#7 -- Result ID = Resource id#9
etc

Adding a sybase_close fixes the problems
Link ID = Resource id#1 -- Result ID = Resource id#2 
Link ID = Resource id#3 -- Result ID = Resource id#4 
Link ID = Resource id#5 -- Result ID = Resource id#6

PHP modules: --with-apache (1.3.12)
             --with-sybase-ct (11.0.0.3)
             --enable-trans-sid

PHP.ini : default except for sybase severity errors on 11

Hope this helps
Thanks
David Clark

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-07-24 23:30 UTC] lyric@php.net
The code as written will not even give you that. If you're posting a bug report, please cut'n'paste the sample code - we can't help if you don't describe your problem properly :)

Anyway, your code is broken :
 - the for loop should be seperated by ; not ,
 - The parameter to sybase_fetch_row() should be $result not $row

Your problem is that sybase_select_db fails every second time. I'm looking at why now.
 [2000-08-23 08:54 UTC] sniper@php.net
Maybe you'll remember this bug now, lyric? =)
 [2000-10-15 07:26 UTC] lyric@php.net
Duplicate of bug 5705. Fixed in CVS 2000/07/20.

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Oct 30 22:01:28 2024 UTC