| 
        php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
  [1998-06-07 19:08 UTC] rgreene at pcpros dot net
 Apparantly, the dBase and regular file functions are colliding on the file identifier assigned? 
$db is the dBase file id where $FILE is the file id.
Comment out the dbase_open line and all is well.
---OUTPUT---
db=1
<br>
<b>Warning</b>:  Unable to find file identifier 1 in <b>./asd</b> on line <b>7</
b><br>
FILE=1
---ENDOUTPUT---
---SCRIPT---
#!/usr/local/bin/php -q
<?
    $db= dbase_open("master.dbf", 0) ||
                die("Couldn't open dBase file: $filename\n");
    printf("db=$db\n");
    $FILE= fopen("junkfile", "w") || die("Could not create junkfile.\n");
    fwrite($FILE, "hi\n");
    printf("FILE=$FILE\n");
    exit;
?>
---ENDSCRIPT---
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits             
             | 
    |||||||||||||||||||||||||||||||||||||
            
                 
                Copyright © 2001-2025 The PHP GroupAll rights reserved.  | 
        Last updated: Tue Nov 04 09:00:01 2025 UTC | 
This is a tricky one -- the result of the || operator is always a boolean value. This means that: $test = "foo" || 5; results in $test == 1. In your example, this means that $db and $FILE are getting set to 1, not the return values of the fopen() and dbase_open() functions.