|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2010-08-20 17:38 UTC] 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.
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Nov 17 20:00:01 2025 UTC |
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 SQLGetDataThe suggested solution: $cnx = odbc_connect('$databaseName', 'user', 'pass', SQL_CUR_USE_ODBC); worked for me. PHP Version 5.3.8 Windows 2003 Server (yeah, still using that) IIS 6.0 Thank you.