Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #2977

Re: fopen error

From "A" <a@a.a>
Newsgroups comp.lang.php
Subject Re: fopen error
Date 2011-08-28 17:23 +0200
Organization B.net Hrvatska d.o.o.
Message-ID <j3dml8$3kh$1@gregory.bnet.hr> (permalink)
References <Hmg6q.167690$7C3.38705@en-nntp-06.dc1.easynews.com>

Show all headers | View raw


> $fpFileOut = fopen($fileout,"c");
> if (!$fpFileOut) {echo "Error opening $fileout\n";  echo E-WARNING; exit;}

do an echo $fileout; before fopen to see what the folder/file is.

remember the following:

- in linux/unix the filenames are case sensitive and file system is a bit 
different than windows
- when you define $fileout remember if you use backslashes you need to 
escape them so it is not
$fileout = "c:\folder\file.txt";
rather
$fileout = "c:\\folder\\file.txt";

in php you can use forward slashes instead which don't require escaping:

$fileout = "c:/folder/file.txt";

- you need to have write permissions (755, 666 etc.) if it is unix/linux 
system. many hosters set this for PHP but you haven't specified what kind of 
host you test this on.

it is probably my lazyness, but unless you really need fopen you can get by 
just fine with much easier functions like readfile, file(), 
file_get_contents(), file_put_contents()... all work done in a single line 
rather than fopen, fread, fwrite, fclose. 

Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

fopen error "eBob.com" <eBob.com@totallybogus.com> - 2011-08-27 20:56 -0400
  Re: fopen error BKDotCom <kent.brad@gmail.com> - 2011-08-27 20:55 -0700
    Re: fopen error "eBob.com" <eBob.com@totallybogus.com> - 2011-08-28 12:00 -0400
  Re: fopen error "A" <a@a.a> - 2011-08-28 17:23 +0200
    Re: fopen error "eBob.com" <eBob.com@totallybogus.com> - 2011-08-28 12:07 -0400
  Re: fopen error "A" <a@a.a> - 2011-08-28 17:27 +0200
  Re: fopen error Denis McMahon <denis.m.f.mcmahon@gmail.com> - 2011-08-28 16:36 +0000

csiph-web