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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Having a problem writing files

Status
Not open for further replies.

rninja

Technical User
Apr 11, 2001
381
US
I have a script that simple takes a variable and places it into a file. Problem is lately the scripts don't write to the file and instead clear the file entirely.

I try in command line on the linux box and it does write, but when launched on the web does not.

Can any one assist? Here is the code:

$line = "Here is the sentence";
// Open the file and erase the contents if any
$fp = fopen("test.inc", "w");
//Write the data to the file
fwrite($fp, $line);
// Close the file
fclose($fp);
echo "Done.";


Rninja

sl_sm.jpg

 
Do yo have the permissions on the folder/file to be able to write to it? That is the first place to look.

Bastien

I wish my computer would do what I want it to do,
instead of what I tell it to do...
 
I am using php4.3.1 on a linux box and permissions are set properly for write access.

As for return values, what do you mean? I do get the echo back out to the browser, but none of the fopen, or file writing activity occurs.

Rninja

sl_sm.jpg

 
retruns are

Code:
if (!$fp = fopen("test.inc", "w"))
{
echo 'couldn't write to file';
}

Bastien

I wish my computer would do what I want it to do,
instead of what I tell it to do...
 
try using this example (straight from the php site)

Bastien

I wish my computer would do what I want it to do,
instead of what I tell it to do...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top