Forum Moderators: coopster

Message Too Old, No Replies

writing data to text file in windows

         

laura2k

9:13 am on Sep 7, 2003 (gmt 0)



hello,

i have the following code that writes to a text file. the problem is it works fine with unix apache but doesnt seem to work with windows IIS. Can anyone please tell me how i can get it to work with IIS.

$fp=fopen("./data/data.db","a");
fwrite($fp,$photoFileName."¡́".$_REQUEST[event]."¡́".$_REQUEST[date]."¡́"
.$_REQUEST[location]."¡́".$_REQUEST[shortdescription]."¡́".$_REQUEST[longdescription]."¡́EOL");
fclose($fp);

Thank You

[edited by: jatar_k at 4:14 pm (utc) on Sep. 7, 2003]
[edit reason] broke line for sidescroll [/edit]

RonPK

10:27 am on Sep 7, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



What exactly doesn't work? Opening the file, or writing the data to the file?
Try some error handling:

$fp=fopen("./data/data.db","a");
if ($fp) {
// fwrite;
} else {
die ("could not open the file");
}

laura2k

10:36 am on Sep 7, 2003 (gmt 0)



the opening of the file works fine, but the data isnt written

RonPK

10:56 am on Sep 7, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Let's do some error handling on fwrite(), then.

if (!fwrite($fp, [your string] )) {
echo "could not write to the file";
} else {
echo "wrote stuff.";
}

vincevincevince

4:36 pm on Sep 7, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I can vouch that that code works 100% fine using apache even under windows... the problem seems to be something to do with IIS - has anyone used fwrite() with IIS before? or someone running php under IIS willing to try it out?

jatar_k

4:39 pm on Sep 7, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



the only note i can see is

[ca.php.net...]

Note: On systems which differentiate between binary and text files (i.e. Windows) the file must be opened with 'b' included in fopen() mode parameter.