View Full Version : Simple php 'write to' script not working??

15 Nov 2007, 08:05 PM
Hi, I am just learning php and in this script I have specified a working link but it is coming up 'can not open file'

Do you have to specify a link in a certain way other than I did?
isn't this suppose to destroy the content of test.php and replace it with 'text to replace'?


// set file to write
$file = 'http://raysantiques.com/test.php';

// open file
$fh = fopen($file, 'w') or die('Could not open file!');

// write to file
fwrite($fh, "text to replace") or die('Could not write to file');

echo $file;

// close file

I fixed it! I changed the link to just test.php and it works now.