php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #9934 faulty dbmfetch()
Submitted: 2001-03-22 12:30 UTC Modified: 2002-05-24 20:15 UTC
From: sma_husain at hotmail dot com Assigned:
Status: Not a bug Package: DBM/DBA related
PHP Version: 4.0.4pl1 OS: Windows NT/2000
Private report: No CVE-ID: None
 [2001-03-22 12:30 UTC] sma_husain at hotmail dot com
sample code:

<?

$db = dbmopen("test007","n");

dbminsert($db,"key1","data1");
dbminsert($db,"key2","data3");
dbminsert($db,"key2","data2");

print "\n<br> Value here should be data1: ";
print dbmfetch($db,"key1");

print "\n<br> Value here should be data2: ";
print dbmfetch($db,"key2");

print "\n<br> Value here should be data3: ";
print dbmfetch($db,"key3");

dbmclose($db);

?>


here is the bug description:

don't even try using this function in php4.x on windows. it is extremely buggy; returns bad data. typically, you will find the first character of inserted data missing, with some wierd chars at the end. on examining the dbm file, it seems the php_dbm.dll methods are incorrectly reading data by skipping the first character, reading the rest of the string and then getting completely messed up because all following string length entries are "shifted". 

i don't know how this huge bug has survived in all php 4.x implementations on windows. it basically renders php 4.x on windows useless for disk based db access. i replaced my 4.x install with 3.x and had no problem running my dbm code. 

please somebody! fix this!

thanks,
amir

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-03-23 08:35 UTC] sniper@php.net
Have you tried using the dba extension instead?
ie. change php_db.dll to php_dba.dll and check
the manual pages for dba extension how to use it:

http://www.php.net/dba

FYI: The db extension is deprecated.

--Jani

 [2001-03-26 10:47 UTC] sma_husain at hotmail dot com
Actually, dba is not really a replacement for dbm. dba requires special libraries to be installed in a PHP server install. If an ISP has chosen to not install those, then dba does not work. Moreover, on Windows platforms there are huge issues with installing dba libraries anyway. The PHP install comes up with:

Warning: no such handler: db2 

I have changed db2 to all other kinds of handlers (including gdbm) and have installed those also, in addition to uncommenting the php_dba.dll include line in php.ini. Doesn't work.

Being deprecated is one thing, but not working is quite another. I would imagine deprecating something implies it will no longer be found in a future version. But shouldn't it work for now? The problem, as I said earlier, is that dbm is the natural fallback when all an ISP/Webhosting platform offers is dbm. dba and other kinds of databases require a custom setup. 

Thanks,
Amir
 [2002-05-24 20:15 UTC] derick@php.net
Thank you for taking the time to report a problem with PHP.
Unfortunately your version of PHP is too old -- the problem
might already be fixed. Please download a new PHP
version from http://www.php.net/downloads.php

If you are able to reproduce the bug with one of the latest
versions of PHP, please change the PHP version on this bug report
to the version you tested and change the status back to "Open".
Again, thank you for your continued support of PHP.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Dec 04 21:01:29 2024 UTC