Re: fopen error [message #175232 is a reply to message #175228] |
Sun, 28 August 2011 16:00 |
eBob.com
Messages: 11 Registered: August 2011
Karma:
|
Junior Member |
|
|
Thanks very much BK. Those tips are going to make my debugging much easier.
(Why don't books mention such aids at the outset?)
My mistake was a dumb logic/typo error which tired eyes were unable to see
last night, but which fresh eyes spotted this morning.
Thanks again, Bob
"BKDotCom" <kent(dot)brad(at)gmail(dot)com> wrote in message
news:781ed9c7-a89d-48eb-bf2b-3aefad6be6bf(at)b9g2000prd(dot)googlegroups(dot)com...
On Aug 27, 7:56 pm, "eBob.com" <eBob....@totallybogus.com> wrote:
> This fopen fails and I don't understand why ...
>
> $fpFileOut = fopen($fileout,"c");
> if (!$fpFileOut) {echo "Error opening $fileout\n"; echo E-WARNING; exit;}
>
> The file does not exist but shouldn't "c" create it? My understand of "c"
> is that it's created if it doesn't exist and overwrites the file if it
> does
> exist. (That's not exactly what the doc says but that is the way I
> understand it.)
Does the directory you're attempting to create the file in exist?
If it does, do you have proper rights to write in it?
Or does the file already exist and you don't have rights to modify it?
> My attemp to echo E-WARNING produces "0". I have no idea what's up with
> that.
"If the open fails, an error of level E_WARNING is generated. You may
use @ to suppress this warning. "
See http://www.php.net/manual/en/book.errorfunc.php
Nutshell E_WARNING is a constant signifying the severity of the error
not a variable describing the last error
To see the actual error open the error log file.
Or
error_reporting(E_ALL ^ E_NOTICE); // report all errors except for
notices
// just in case it's
currently set to to report no errors
ini_set('display_errors',1); // output the error
// (in addition to writing it
to error log)
Or, if you've got PHP >= 5.2, you can try
print_r(error_get_last());
anyhow, once you view see the error, you should know the reason for
the error. :)
|
|
|