php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #10181 odbc_result causes Unexpected network read error
Submitted: 2001-04-05 06:37 UTC Modified: 2002-01-21 09:42 UTC
From: f dot schneider at de-bleek dot demon dot nl Assigned:
Status: Closed Package: ODBC related
PHP Version: 4.0.4pl1 OS: Linux
Private report: No CVE-ID: None
 [2001-04-05 06:37 UTC] f dot schneider at de-bleek dot demon dot nl
Configuration bulld with

'./configure' '--with-openlink=/opt' '--sysconfdir=/etc' '--with-apxs=/var/lib/apache/sbin/apxs'

Problem also occures when using --with-iodbc

The database I connect to is a Progress 7.3E15 database. Using the odbctest program all works fine: i.e. it does not seem to be a problem with the openlink or iodbc code.

This is the code that results in the error

<HTML>
<HEAD>
<TITLE>Query ps_mstr</TITLE>
</HEAD>
<BODY>
<?php
	$part = '9450001';	
	putenv("LD_LIBRARY_PATH=/opt/odbcsdk/lib");
	putenv("ODBCINI=/etc/odbc.ini");

	$dsn = "DSN=qaddb";
	$sql = "select ps_comp from ps_mstr where ps_par = '$part'";

	echo "<P>Query is $sql</P>\n";
	if ($conn_id = odbc_connect("$dsn","","")) {
		echo "<P>Database connection succeeded</P>\n";
		if ($result = odbc_do($conn_id, "$sql")) {
			echo "<P>Query succesfully submitted</P>\n";
/*
			odbc_result_all($result);
*/
			while (odbc_fetch_row($result)) {
				$comp = odbc_result($result, 1);
				echo "<P>$comp</P>\n";
			}
			odbc_free_result($result);
		} else {
			echo "<P>Problem submitting query</P>\n";
		}
		odbc_close($conn_id);
	} else {
	}

?>

Using lynx as a browser, I get the following errors:

Alert!: Unexpected network read error; connection aborted.


The code works fine if I give $part the value "STRATOS". It seems that the code breaks when the query looks for records with key values that start with a number _and_ when more than one row is being returned. 

odbc_result_all also gives strange. The output with odbc_result_all and $part = 9450001 looks like:

ps_comp 
Openlink_DSN=qaddb___2 
Openlink_DSN=qaddb___2 
Openlink_DSN=qaddb___2 
Openlink_DSN=qaddb___2 
Openlink_DSN=qaddb___2 

The php.ini file is the same as php.ini-dist expect for output buffering being enabled.

Hope this helps

TIA

Frans Schneider
work: f.schneider@nido.nl
home: f.schneider@de-bleek.demon.nl

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-04-09 10:25 UTC] kalowsky@php.net
is this the latest version of OpenLink?
 [2001-05-01 14:50 UTC] f dot schneider at de-bleek dot demon dot nl
This is with the odbclib 1.0.0 from the ODBC SDK and libiodbc 2.0.12 which is included with it. I am trying to get the libiodc 2.1.3 working but did not succeed yet.

Frans
 [2001-05-02 05:08 UTC] f dot schneider at de-bleek dot demon dot nl
Sorry about the incorrect library names. The details are:

the openlink odbc driver is oplodbc.so.1.0.0
the iodbc driver manager is libiodbc.so.2.0.12 as packaged with the openlink odbc sdk.

This morning I got the newest version 3.0.4 working of libiodbc. The driver is still the same oplodbc.so.1.0.0 and libiodbc now has version libiodbc.so.2.1.3. 
I still have the same problem!!

NB
It took me a while to figure out the odbc_connect has changed: Before I had to use:


$dsn = "DSN=qaddb";
if ($conn_id = odbc_connect("$dsn","","")) {
    ...

Now this has to be:

$dsn = "qaddb";
if ($conn_id = odbc_connect("$dsn","","")) {
    ...


 [2001-06-01 17:23 UTC] f dot schneider at de-bleek dot demon dot nl
Hitting the refresh button on the browser will return different results each time. The number of rows seems correct. It doesn't look like a problem with the drivers since they work fine with Python or the test programm included with the driver. Could this be a problem with type casting? Where should I look in the PHP source code?
 [2001-06-10 16:11 UTC] kalowsky@php.net
you can look in the ext/odbc/php_odbc.c file for what might 
be causing this.  the ext/odbc/php_odbc.h may also be of 
some help.

also you might wish to try the 4.0.5 release of PHP, or 
possibly the 4.0.6RCs (4.0.5 was in RC for a LONG time).
 [2001-06-13 09:03 UTC] f dot schneider at de-bleek dot demon dot nl
Version 4.0.5 has exactly the same problem. Could this be a problem with type conversion? How should I debug?
 [2001-06-21 11:20 UTC] kalowsky@php.net
best way to debug is to build as a CGI and set a break in the function you think might be causing it.  then run and step through the code.  
 [2001-07-04 07:01 UTC] f dot schneider at de-bleek dot demon dot nl
After some debugging of the ODBC module of php we have 
discoverd that the SQLExtendedFetch function of the 
OpenLink-progress driver is buggy. 

an query like:
select * from table where field='text'

will give us a valid result set, but an query like:

select * from table where field='12345'

will give us garbage: The driver does not set the 
'result->values' arrays (but it returns SUCCESS and sets 
the correct number of collumns etc.) this results in 
variables which
are pointing to some non-set, non-terminating strings ...

The reason why python and the example programm work is 
that they don't use the SQLExtendedFetch function but 
SQLFetch.

The fix for this problem is to undefine the 
HAVE_SQL_EXTENDED_FETCH definition in php_odbc.h
at the iODBC definitions (if you use iODBC with openlink)
or else at the OpenLink definitions.

Maybe the php folks can give an extra option for 
openlink-progress ? so this can be solved more accurate?

Thanks.








 [2001-07-05 08:41 UTC] kalowsky@php.net
This sounds like a problem with the PHP cursor implementation, not OpenLink.

Stephan Schadt and I have been working on a solution for this, and should hopefully have one ready in the near future.  I'd like to say 4.0.7, but I'm not entirely sure.
 [2002-01-21 09:42 UTC] kalowsky@php.net
This should be fixed in CVS now.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Apr 20 15:01:29 2024 UTC