#11394 [Com]: PHP does not read from or write to flat file properly
| From: | FETISH-SMOKING219 at hotmail dot com | Date: | Tue, 20 Jul 2004 15:06:16 +0000 |
| Subject: | #11394 [Com]: PHP does not read from or write to flat file properly | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-62967@lists.php.net to get a copy of this message | ||
ID: 11394
Comment by: FETISH-SMOKING219 at hotmail dot com
Reported By: ridley at net2000 dot com dot au
Status: Closed
Bug Type: DBM/DBA related
Operating System: Win98 (2nd ed, 4.10.2222.A)
PHP Version: 4.0.5
New Comment:
<a href=http://www.geocities.com/vgdsxdgyw5972/>FETISH
SMOKING</a>
Previous Comments:
------------------------------------------------------------------------
[2001-06-12 03:25:33] sniper@php.net
The db extension (dbm) is deprecated and not developed
anymore. You should try using the dba extension instead.
Please try it and if this happens with it too, reopen.
--Jani
------------------------------------------------------------------------
[2001-06-11 02:47:12] ridley at net2000 dot com dot au
I am new to php and DBMs, and I have trouble reading from (or writing
to) the DBM flat file.
Other possibly related bugs: Bug id #9222 and #9283
The writer code:
<?PHP
$fn = "./DBMData/products";
$dbh = dbmopen($fn,"c") or die ("Couldn't open test DBM");
$item="Screwdriver";
$item_p="12.34";
if (dbmexists ($dbh, $item)) {
dbmreplace($dbh, $item, $item_p);
} else {
dbminsert ($dbh, $item, $item_p);
}
$item="Tricorder";
$item_p="2.34";
if (dbmexists ($dbh, $item)) {
dbmreplace($dbh, $item, $item_p);
} else {
dbminsert ($dbh, $item, $item_p);
}
$item="ORAC";
$item_p="98.76";
if (dbmexists ($dbh, $item)) {
dbmreplace($dbh, $item, $item_p);
} else {
dbminsert ($dbh, $item, $item_p);
}
$item="HAL 2000";
$item_p="99.97";
if (dbmexists ($dbh, $item)) {
dbmreplace($dbh, $item, $item_p);
} else {
dbminsert ($dbh, $item, $item_p);
}
dbmclose($dbh);
?>
The DBM file created:
11
Screwdriver5
12.349
Tricorder4
2.344
ORAC5
98.768
HAL 20005
99.97
The reader code:
<?PHP
$fn = "./DBMData/products";
$dbh = dbmopen($fn,"c") or die ("Couldn't open test DBM");
$key = dbmfirstkey($dbh);
while ($key != "")
{
$value = dbmfetch($dbh, $key);
print "<TR>";
print "<TD ALIGN=\"left\">$key</TD>";
print "<TD ALIGN=\"right\">\$$value</TD>";
print "</TR>\n";
$key = dbmnextkey($dbh, $key);
}
dbmclose($dbh);
?>
The output:
crewdriver5 $
Tricorder $2.34
ORAC $98.76
HAL 2000 $9.972
Thanks in advace,
Ridley
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=11394&edit=1