note 14445 added to function.odbc-result.php
| From: | huevo dot SP at M dot earthling dot net | Date: | Tue, 31 Jul 2001 19:46:00 +0000 |
| Subject: | note 14445 added to function.odbc-result.php | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-16130@lists.php.net to get a copy of this message | ||
With an Access 2K database, odbc_result will only work the first time it is called on a memo field
(odbc_field_type returns 'LONGCHAR').
$good = odbc_result($result,'Description');
# $good holds the field value
$fail = odbc_result($result,'Description');
# $fail holds false
This tripped me up when I did something like this:
for ($i=1; $i<=odbc_num_fields($result); $i++) {
if(odbc_result($result,$i)){
... more code ...
echo odbc_result($result,$i);
... snip ...
}
}
For any field type except memo, this code works perfectly. But on memo fields, odbc_result returns
false on the second call and nothing is echoed.
Be careful, use a temporary variable instead of multiple calls to odbc_result. (It's good
programming practice anyway)
for (...) {
$temp = odbc_result($result,$i);
if($temp){
...
echo $temp;
...
}
}
http://www.php.net/manual/en/function.odbc-result.php