php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #3371 dbmfetch reurns an empty string
Submitted: 2000-02-01 06:54 UTC Modified: 2005-03-31 16:13 UTC
From: kredel at rz dot uni-mannheim dot de Assigned:
Status: Wont fix Package: DBM/DBA related
PHP Version: 3.0.12 OS: Linux
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2000-02-01 06:54 UTC] kredel at rz dot uni-mannheim dot de
A counter function written in php and using gdbm is no more
working. the dbmfetch funktion returns empty string, while
dbmexists indicates the existence of an string. looking 
into the dbm file shows the value is there. I include first
the output of two different systems (the first is th buggy one) and then the php script.
----------
PHP mit dbm:

Datei: /home4/kredel/public_html/ex51.phtml.

open: 1

key: /home4/kredel/public_html/ex51.phtml

found: ####

put: 1

replace: 1

1 Zugriffe, Ge?ndert am 01 Feb 2000 12:38:08

DB Version: This is GDBM version 1.7.3, as of May 19, 1994.

Hostname: trumpf-5.rz.uni-mannheim.de

Server Software: Apache/1.3.9 (Unix) PHP/3.0.12
----------
PHP mit dbm:

Datei: /home4/kredel/public_html/ex51.phtml.

open: 1

key: /home4/kredel/public_html/ex51.phtml

found: ##129##

put: 130

replace: 130

130 Zugriffe, Ge?ndert am 01 Feb 2000 12:38:08

DB Version: This is GDBM version 1.7.3, as of May 19, 1994.

Hostname: trumpf-4.rz.uni-mannheim.de

Server Software: mod_perl/1.18 Apache/1.3.4 (Unix) (SuSE/Linux) PHP/3.0.7
----------
<?php
$filename=$SCRIPT_FILENAME;
function modified($lang) {
        global $filename;
        $lm=date("d M Y H:i:s",filectime($filename));
        if ($lang=="de") {
           return "Ge&auml;ndert am $lm";
        } else {
           return "Last modified: $lm";
        }
}

$filename=$SCRIPT_FILENAME;
$counter_start="1";
function counter() {
        global $filename, $counter_start;
        $counter_dir="/tmp/";
        $counter_db=$counter_dir . "zaehler.dbm";
        if (file_exists("$counter_db")) {
           $db=dbmopen($counter_db,"w");
           echo "<p>open: $db</p>";
           echo "<p>key: $filename</p>";
           if ( dbmexists($db,$filename) ) {
               $cnt=dbmfetch($db,$filename);
               echo "<p>found: ##$cnt##</p>";
               if ($counter_start=="1") { $cnt++; } 
               else { $cnt=$counter_start; }
               echo "<p>put: $cnt</p>";
               dbmreplace($db,$filename,$cnt);
               echo "<p>replace: $cnt</p>";
           }
           else {
               $cnt=$counter_start;
               dbminsert($db,$filename,$cnt);
           }
           dbmclose($db); 
           return "$cnt";
        }
        else {
           echo "Attempt to create file: " . $counter_db;
           $cnt=$counter_start;
           $db=dbmopen($counter_db,"n");
           dbminsert($db,$filename,$cnt);
           dbmclose($db);
           return "$cnt";
        }
}
?>

<html>
<head>
<title>php dbm</title>
</head>
<body>
<p>PHP mit dbm:</p>
<p>
<?php 

  /* $counter_start="9999"; */
  echo "<h3>Datei: $SCRIPT_FILENAME.</h3>"; 
  echo "<h3>" . counter(). " Zugriffe,";
  echo " " . modified("de") . "</h3>"; 

  $yyy=dblist();
  echo "<p>DB Version: $yyy</p>";

  echo "<p>Hostname: $HTTP_HOST</p>";
  echo "<p>Server Software: $SERVER_SOFTWARE</p>";

?>

</body>
----------

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-03-31 16:13 UTC] php-bugs at lists dot php dot net
We are sorry, but we do not support PHP 3 related problems anymore.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 14:01:29 2024 UTC