php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #6572 ODBC_result cannot fetch MEMO fields from MS Access
Submitted: 2000-09-06 05:23 UTC Modified: 2000-09-26 21:58 UTC
From: mischa at szeker dot ch Assigned:
Status: Closed Package: ODBC related
PHP Version: 4.0.1pl2 OS: Win NT 4.0
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: mischa at szeker dot ch
New email:
PHP Version: OS:

 

 [2000-09-06 05:23 UTC] mischa at szeker dot ch
ODBC_result cannot fetch MEMO fields from MS Access

<?php $dsn = "szeker";
$user = "administrator";
$passwort = "";
$verbindung = odbc_connect($dsn, $user, $passwort);
$sql = "SELECT * FROM tGuestbook";
$ergebnis = odbc_exec($verbindung, $sql);

echo "<table>\n";
echo "<tr>";
echo "<td>";
echo odbc_result($ergebnis, "Name");
echo ",<br>\n";
echo "<a href=\"mailto:";
echo odbc_result($ergebnis, "Email");
echo "\">";
echo odbc_result($ergebnis, "Email");
echo "</a><br>\n";
echo odbc_result($ergebnis, "Date");
echo ",<br>\n";
echo odbc_result($ergebnis, "Time");
echo "</td>";
echo "<td>";
echo odbc_result($ergebnis, "Memo");
echo "</td>";
echo "</table>";

odbc_free_result($ergebnis);
odbc_close($verbindung);
?>

I always get the following error message when I run this script: Warning: SQL error: [Microsoft][ODBC Driver Manager] Invalid cursor state, SQL state 24000 in SQLGetData in c:\program files\apache group\apache\htdocs\szeker\new\guestbook.php on line 37

And I'm not the only one - in the language reference there is another user with exactly the same problem. If I change the data type from Memo to Text, everything works fine. But I need more than 255 characters in this field. Is there another possibility to query this field? Or will this bug be fixed?


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-09-09 23:57 UTC] torben@php.net
Moved in from Bug Report #6645; this appears to be a way of coping.
Can the original poster tell whether this helps? - Torben
------------------------------------------------------------
Oddly, this also happens in ASP/vbscript, however you can MEMO fields to work correctly
with the following:

You can get MEMO fields to work.  Right now it takes some finesse.

#1) You may try adding SQL_CUR_USE_ODBC

#2) You need to use odbc_longreadlen before you use odbc_fetch_row, otherwise it will not
read enough characters.

#3) As of 4.0.2, making odbc_longread too long may cause PHP to become unstable.

#4) You may need to make a query that only returns the MEMO field to read it correctly. 
Otherwise it sometimes just doesn't work (this is similar in ASP and so is probably a bug
with Access or ODBC drivers for it.)

Example:

$conn = odbc_connect( $DSN, $user, $pw, $SQL_CUR_USE_ODBC );
$result = odbc_exec( $conn, $query );
odbc_longreadlen( $result, 1000000);

/* Your odbc_fetch_row, etc, will now work */
 [2000-09-20 22:38 UTC] mischa at szeker dot ch
Thanks for your help - it solved the problem. Only one thing doesn't work correctly - the carriage returns. It seems that they are converted to spaces. But I'll try to figure this out myself.

Thanks again,
mischa@szeker.ch
 [2000-09-26 21:58 UTC] sniper@php.net
Solved.

--Jani
 [2002-12-18 12:07 UTC] mnewman at dragonorth dot com
I get the same failure.

When I create a new selection that only gets the Memo field and DOES NOT specify
 	odbc_longreadlen($result, 1000000);
the memo field is fetched correctly.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 16:01:29 2024 UTC