Edit report at http://bugs.php.net/bug.php?id=52658&edit=1
ID: 52658
User updated by: cyoung at gcs dot neric dot org
Reported by: cyoung at gcs dot neric dot org
Summary: odbc_fetch_row doesn't fetch memo field
Status: Open
Type: Bug
Package: ODBC related
Operating System: Windows Sever 2008
PHP Version: 5.3.3
Block user comment: N
New Comment:
I was able to find a way to fix this "problem" I was having when using
odbc_fetch_row with memo fields. When I connected to the database I
used the optional cursor_type parameter.
$cnx = odbc_connect('$databaseName', 'user', 'pass', SQL_CUR_USE_ODBC);
This seemed to allow odbc_fetch_row to retrieve the memo field
successfully. I was getting the error below before inserting the cursor
type into odbc_connect.
PHP Warning: odbc_result() [<a
href='function.odbc-result'>function.odbc-result</a>]: SQL error:
[Microsoft][ODBC Microsoft Access Driver]Invalid cursor position; no
keyset defined , SQL state S1109 in SQLGetData
Previous Comments:
------------------------------------------------------------------------
[2010-08-20 17:38:42] cyoung at gcs dot neric dot org
Description:
------------
odbc_fetch_row doesn't retrieve a memo field from MS access db. It does
however retrieve all the other fields in the same row successfully.
Without the use of odbc_fetch_row, odbc_result retrieves the memo field
exactly as expected. This obviously poses a problem only when trying to
retrieve more than one row in a database, which is usually the case more
than not.
Test script:
---------------
while(odbc_fetch_row($result)) {
$newsID = odbc_result($result, "newsID");
$newsTitle = odbc_result($result, "newsTitle");
$titleLink = odbc_result($result, "titleLink");
$brief = trim(odbc_result($result, "brief"));
$link = $titleLink.$newsID;
$newsBrief = substr($brief, 0, 75);
echo "<div id=\"newsLink\" class=\"newsTitle\"><a href=\"$link\"
onclick=\"window.open('$link', 'GCSNews', 'width=500, height=400,
menubar=no, toolbar=no, resizable=no, top=100, left=200'); return
false;\">$newsTitle</a></div>";
echo "<div class=\"newsBrief\">$newsBrief...</div>";
}
Expected result:
----------------
I expected the memo field "brief" to be fetched, trimmed, and then a
substring of the first 75 characters to be stored in $newBrief and print
out followed by ...
Actual result:
--------------
...
when trouble shooting, just echoing $brief showed nothing in the
browser. $brief is an empty string when used in conjunction with
odbc_fetch_row.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=52658&edit=1