Search Webmaster Help and Solution

[RESOLVED] Got a problem with file_exists...

Why would this code print true if called before instantiating the
CSVFixImport class:
PHP Code: require(class.csv.php); // class file and test script are in webroot.
echo (file_exists(file_uploads/KRN_080110.fle)?true:false);
but when instantiating this class and trying to set the CSVFile property
the file_exists call prints
file_uploads/KRN_080110.fle file does not exist or no read access?
PHP Code: $csv_import2 = new CSVFixImport;
$csv_import2->setFile(file_uploads/KRN_080110.fle);
CSVFixImport class setFile function: PHP Code:   function setFile($file)
  {
    $this->CSVFile = $file;
    // prints file_uploads/KRN_080110.fle
    // echo $this->CSVFile
    if(file_exists($this->CSVFile)) {
      $this->CSVError[] = $this->CSVFile . file does not exist or no read access;
      return FALSE;
    } else {
      if(($this->CSVFile != none) && !empty($this->CSVFile)) {
        $this->setData(join(,file($this->CSVFile)));
      } else {
        $this->CSVError[] = CSVFile property none or empty;
        return FALSE;
      } // if(($this->CSVFile != none) && !empty($this->CSVFile))
    } // if(file_exists($this->CSVFile))
  } // function setFile($file)
Why would this code print true if called before instantiating the
CSVFixImport class:
PHP Code: require(class.csv.php); // class file and test script are in webroot.
echo (file_exists(file_uploads/KRN_080110.fle)?true:false);
but when instantiating this class and trying to set the CSVFile property
the file_exists call prints
file_uploads/KRN_080110.fle file does not exist or no read access?
PHP Code: $csv_import2 = new CSVFixImport;
$csv_import2->setFile(file_uploads/KRN_080110.fle);
CSVFixImport class setFile function: PHP Code:   function setFile($file)
  {
    $this->CSVFile = $file;
    // prints file_uploads/KRN_080110.fle
    // echo $this->CSVFile
    if(file_exists($this->CSVFile)) {
      $this->CSVError[] = $this->CSVFile . file does not exist or no read access;
      return FALSE;
    } else {
      if(($this->CSVFile != none) && !empty($this->CSVFile)) {
        $this->setData(join(,file($this->CSVFile)));
      } else {
        $this->CSVError[] = CSVFile property none or empty;
        return FALSE;
      } // if(($this->CSVFile != none) && !empty($this->CSVFile))
    } // if(file_exists($this->CSVFile))
  } // function setFile($file)

View Complete Thread with Replies

Related Items

Query failed: connection to localhost:3354 failed (errno=111, msg=Connection refused).