#6572 [Com]: ODBC_result cannot fetch MEMO fields from MS Access
| From: | mnewman at dragonorth dot com | Date: | Wed, 18 Dec 2002 18:07:35 +0000 |
| Subject: | #6572 [Com]: ODBC_result cannot fetch MEMO fields from MS Access | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-27980@lists.php.net to get a copy of this message | ||
ID: 6572
Comment by: mnewman@dragonorth.com
Reported By: mischa@szeker.ch
Status: Closed
Bug Type: ODBC related
Operating System: Win NT 4.0
PHP Version: 4.0.1pl2
New Comment:
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.
Previous Comments:
------------------------------------------------------------------------
[2000-09-26 21:58:06] sniper@php.net
Solved.
--Jani
------------------------------------------------------------------------
[2000-09-20 22:38:55] mischa@szeker.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-09 23:57:15] 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-06 05:23:54] mischa@szeker.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?
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=6572&edit=1