$记录未传递该值

Since migrating to PHP7.1, "$record" is no longer writing to the db.

It is still adding +1 record to the index but it does not write the actual information into the file namefile.dat.

namefile.dat permission is set to 644, but the file still returns empty, with no data.

if (!$db->open("../namefile"))    {
    $schema = array(
        array("key", FFDB_INT, "key"),
        array("nname", FFDB_STRING),
        array("desc", FFDB_STRING),
        array("daya", FFDB_INT),
        array("yeara", FFDB_INT)
        );
    // Try and create it...
    if (!$db->create("namefile", $schema))       {
        echo "Error creating database
";
        return;
    }
}
$record["key"] = $data;
$record["nname"] = ucwords($datana);
$record["desc"] = $desc;
list($record["daya"]) = sscanf($daya, "%d"); // string -> int
list($record["yeara"]) = sscanf($yeara, "%d"); // string -> int

Any ideas? Because I tried changing to $_POST to force it....

   $record["key"] = $_POST[$data];
   $record["nname"] = ucwords($_POST["$datana"]);
   $record["desc"] = $_POST["$desc"];
   list($record["daya"]) = sscanf($_POST["$daya", "%d"]);
   list($record["yeara"]) = sscanf($_POST["$yeara", "%d"]);

....but still failing in writing the values to the file.

Any suggestions?

Thanks

EDITING

Error log is pointing to these 2 functions -

 function read_byte($fp)     {
    return $this->bin2dec(fread($fp, 1), 1);
 }


function read_str($fp)     {
    $strlen = $this->bin2dec(fread($fp, 4), 4);
    return fread($fp, $strlen);
 }

NOTE: bin2dec works as like bindec, no errors

The bin2dec method is defined as:

function bin2dec(&$str, $len)

So the first parameter is declared to be a reference variable. This means that when you call it, the corresponding argument has to be a variable that can be updated. But it's being called like this:

  return $this->bin2dec(fread($fp, 4), 4);

You can't use a function call as the argument when the function parameter is a reference variable, since there's no variable for it to reference.

There's actually no reason why the first argument to bin2dec() needs to be a reference, since the function never modifies it. Change the function definition to:

function bin2dec($str, $len)

FFDB seems to have lots of unnecessary reference variables and function parameters. It's pretty old code (over 16 years old), maybe in earlier versions of PHP this was useful to prevent unnecessary copying. PHP has been using copy-on-write for many years now, so there's no need to use references for this purpose any more.

I edited ffdb.inc.php and replaced all &$ with $ except for:

function add(&$record)

This seems to be needed for FFDB_INT_AUTOINC columns, which are modified in place in $record when storing.

After doing this I didn't get any Only variables should be passed by reference errors.