php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #13783 odbc_fetch_into different issue
Submitted: 2001-10-21 20:59 UTC Modified: 2002-08-24 01:00 UTC
From: Grant dot Walters at walters dot co dot nz Assigned: ahill (profile)
Status: No Feedback Package: ODBC related
PHP Version: 4.0.6 OS: SCO Openserver 5.0.5 & RH Lnux 7
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: Grant dot Walters at walters dot co dot nz
New email:
PHP Version: OS:

 

 [2001-10-21 20:59 UTC] Grant dot Walters at walters dot co dot nz
Platforms:
Using PHP 4.0.6/Openlink 4.1/Progress 8.3D.

Other:
I've tried PHP 4.0.4/4.0.5/4.0.6, Openlink 3.2,4.0,4.1, Progress 8.3C,8.3D,9.1C, shared memory and TCP/IP based connections.

Problem:
Doesn't seem to matter what I do, I am completely unable to select specific rows using ODBC.
I think the code below is correct, it's snipped from scripts.

<?
$dsn="DSN=$database;UID=$user;PWD=$password";

// I've tried all these without a difference.
$cursor="SQL_CUR_USE_ODBC";
//$cursor="SQL_CUR_IF_NEEDED";
//$cursor="SQL_CUR_USE_DRIVER";
//$cursor="SQL_CUR_DEFAULT";
$sql="SELECT * FROM user_table";
$text="";

function db_fetch_into($id, $number) {
global $text;
$text = "<TD>ROW: $number</TD>";
  //Never Returns Anything
  //odbc_fetch_into($id, $number, $result_array);
  //Always Works
  odbc_fetch_into($id, $result_array);
  //Always Works
  //odbc_fetch_into($id, 0, $result_array);
  return $result_array;
}

if ($conn=odbc_connect("$dsn","","","$cursor")){
  echo "<TABLE border='1'>";
  //while ((odbc_fetch_into($results,$pos,$row)) && ($count<$limit)) {
  $pos=0;
  while ((list($var1,$var2) = db_fetch_into($result, $pos)) && ($pos<10)) {
    echo "<TR>$text<TD>$var1</TD><TD>$var2</TD></TR>";
    $pos ++;
  }
  echo "</TABLE>";
  odbc_free_result($result);
  odbc_close($conn);
} else {
  // No connection .....
}

?>

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-10-22 09:38 UTC] ahill@php.net
Are you getting error messages?

Also, please generate an odbc trace; uncomment the DebugFile section in odbc.ini.

Best regards,
Andrew Hill
OpenLink Software
 [2001-10-22 10:31 UTC] jpm@php.net
Status -> Feedback
 [2001-10-22 20:56 UTC] Grant dot Walters at walters dot co dot nz
Using odbc_fetch_into($id, $number, $result_array);

SQLAllocHandle ( ... )
SQL_SUCCESS

SQLSetStmtAttr ( ... )
SQL_SUCCESS

SQLAllocHandle ( ... )
SQL_SUCCESS

SQLDriverConnect ( ... )
SQL_SUCCESS

SQLGetInfo ( ... )
SQL_SUCCESS

SQLGetInfo ( ... )
SQL_SUCCESS

SQLAllocHandle ( ... )
SQL_SUCCESS

SQLGetStmtAttr ( ... )
SQL_SUCCESS

SQLGetStmtAttr ( ... )
SQL_SUCCESS

SQLGetStmtAttr ( ... )
SQL_SUCCESS

SQLGetStmtAttr ( ... )
SQL_SUCCESS

SQLGetInfo ( ... )
SQL_SUCCESS

SQLSetStmtAttr ( ... )
SQL_SUCCESS

SQLExecDirect ( ... )
SQL_SUCCESS

SQLNumResultCols ( ... )
SQL_SUCCESS

SQLNumResultCols ( ... )
SQL_SUCCESS

SQLColAttribute ( ... )
SQL_SUCCESS

SQLColAttribute ( ... )
SQL_SUCCESS

SQLColAttribute ( ... )
SQL_SUCCESS

SQLBindCol ( ... )
SQL_SUCCESS

SQLColAttribute ( ... )
SQL_SUCCESS

SQLColAttribute ( ... )
SQL_SUCCESS

SQLColAttribute ( ... )
SQL_SUCCESS

SQLBindCol ( ... )
SQL_SUCCESS

SQLColAttribute ( ... )
SQL_SUCCESS

SQLColAttribute ( ... )
SQL_SUCCESS

SQLColAttribute ( ... )
SQL_SUCCESS

SQLBindCol ( ... )
SQL_SUCCESS

SQLColAttribute ( ... )
SQL_SUCCESS

SQLColAttribute ( ... )
SQL_SUCCESS

SQLColAttribute ( ... )
SQL_SUCCESS

SQLBindCol ( ... )
SQL_SUCCESS

SQLColAttribute ( ... )
SQL_SUCCESS

SQLColAttribute ( ... )
SQL_SUCCESS

SQLColAttribute ( ... )
SQL_SUCCESS

SQLBindCol ( ... )
SQL_SUCCESS

SQLColAttribute ( ... )
SQL_SUCCESS

SQLColAttribute ( ... )
SQL_SUCCESS

SQLColAttribute ( ... )
SQL_SUCCESS

SQLBindCol ( ... )
SQL_SUCCESS

SQLColAttribute ( ... )
SQL_SUCCESS

SQLColAttribute ( ... )
SQL_SUCCESS

SQLColAttribute ( ... )
SQL_SUCCESS

SQLBindCol ( ... )
SQL_SUCCESS

SQLExtendedFetch ( ... )
SQL_SUCCESS

SQLExtendedFetch ( ... )
SQL_ERROR

SQLFreeHandle ( ... )
SQL_SUCCESS

SQLDisconnect ( ... )
SQL_SUCCESS

SQLFreeHandle ( ... )
SQL_SUCCESS

SQLFreeHandle ( ... )
SQL_SUCCESS

 [2001-10-22 20:59 UTC] Grant dot Walters at walters dot co dot nz
No errors at all, just returns an empty recordset.

One probably important note.  When I compiled PHP 4.0.6 I had to remove the reference to isql.h? in the php_odbc source program as it wasn't in the Openlink SDK for Openlink 4.1.

Everything seems to work except the selected record stuff which hasn't ever worked for me using PHP 4 against Openlink.

I think I had it working under PHP 3.0.15 against Openlink 3.2, but we have moved on since then.
 [2001-10-23 10:10 UTC] ahill@php.net
The current SDK version is 3.0.5 and isql.h is included in it. Please get the SDK from either www.openlinksw.com or www.iodbc.org and recompile without commenting out the references.

Best regards,
Andrew Hill
OpenLink Software

 [2001-10-23 22:43 UTC] Grant dot Walters at walters dot co dot nz
A correction to my previous information:

The piece I commented out was in the php_opdbc.h file and was a reference to iodbc.h.  This file is not present in the V4 ODBCSDK.

I am unable to determine exactly which version of the SDK is being used as the Openlink ODBCSDK files have no version numbers anywhere.

However....

I have gone back to what I had with the Openlink 3.2 drivers (and put back the iodbc.h line).  The same thing happens regarding the sql query containing a (').

However....

The Openlink team suggested a series of changes including using odbc_prepare.

Using 3.2 and 4.1 the following works.
$sql="SELECT ID,Category,description FROM card_type WHERE description=?";
$results = odbc_prepare($conn,$sql);
$parms=array("PEPPERELL'S");
odbc_execute($results,$parms);
if ($results) {
  while (odbc_fetch_into($results,$row)) {
    echo $row[0]." ".$row[1]." ".$row[2]."<BR>";
  }
}

I still think it has to be a bug with on the PHP side to do with how PHP parses the $sql contents, that is resulting in a syntax error in the SQL statement passed to Openlink.

According to the Microsoft ODBC SDK, error 37000 is remapped to 42000 which says:

42000: *StatementText contained an SQL statement that was not preparable or contained a syntax error. 
The user did not have permission to execute the SQL statement contained in *StatementText.

This is definitely not a permission issue.

Openlink alse mentioned changes to disable the use of DYNAMIC_CURSOR.  As I currently can make the queries I need (so far), I will carry on with what I have.

 [2001-10-23 22:45 UTC] Grant dot Walters at walters dot co dot nz
Sorry about the last post.  It is a different issue that I haven't raised yet.  Can someone remove it.
 [2001-10-24 05:13 UTC] Grant dot Walters at walters dot co dot nz
A correction to my previous information:

The piece I commented out was in the php_opdbc.h file and was a reference to iodbc.h. 
This file is not present in the Openlink V4.1 ODBCSDK.

I am unable to determine exactly which version of the SDK is being used as the Openlink
ODBCSDK files have no version numbers anywhere.

I have just finished testing against the SDK I downloaded with Openlink 3.2 bits.

The odbc_fetch_into($results,$pos,$row) code works with both odbc_do and odbc_prepare statements, so it must be something to do with the new 4.1 SDK.




 [2002-06-24 22:51 UTC] kalowsky@php.net
Can you please try a more recent release?  All my local testing has proven to be successful using iODBC.  

If upgrading to a newer version doesn't work, can you please provide a simplified version of your sample script to reproduce this?  
 [2002-06-25 15:55 UTC] Grant dot Walters at walters dot co dot nz
I have moved onto latest versions of RH, Openlink and PHP.  Testing resumes at the end of next week.
 [2002-07-23 11:29 UTC] kalowsky@php.net
setting to feedback until further notice is given by end user.
 [2002-08-24 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 13:01:29 2024 UTC