Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Writing to file

Status
Not open for further replies.

BRM

Technical User
Apr 15, 2002
2
US
Here's the script:
Code:
<html>
<title>File Write Experiment</title>
<body>
We will attempt to write a file called &quot;test.dat&quot; and store some
stuff in it.
<?php
$myfile = fopen(&quot;test.dat&quot;,&quot;w&quot;);
print &quot;The file $myfile should now be opened.
&quot;;
print &quot;<HR>&quot;;
$number=0;
while($number<5)
{
print &quot;Now writing... $number
&quot;;
$fp = fwrite($myfile,&quot;$number,&quot;);
$number++;
}
$fp = fwrite($myfile,$number);
$fp = fwrite($myfile,chr(13));
$fp = fwrite($myfile,&quot;DONE&quot;);
fclose($myfile);
?>
The file should now be closed.
</body>
</html>
but here's the output:

We will attempt to write a file called &quot;test.dat&quot; and store some
stuff in it.
The file Resource id #1 should now be opened.
Now writing... 0
Now writing... 1
Now writing... 2
Now writing... 3
Now writing... 4
The file should now be closed.

Note Resource id #1
Is that right, and if so, the output file only contains DONE with no CR after it

my setup:
PHP 4.1.2
Apache 1.3.23
And Mandrake Linux 8.2
and help would be great
 
Got it fixed, sorry for wasting your time.
 
Hi,

I tested your script and on my account it works just fine.

So I really don't know what the problem might be...
Do you have enough permission to write to the directory?
Are you sure you've all the names right? And be sure to remove the Return between 'opened' and te '&quot;' in you're print statement...

If the problem keeps excisting, write back...

Greeting
Bram
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top