...

View Full Version : using fwrite



graziano
11-21-2006, 05:04 PM
Hi

I have a file (test.txt) containing these lines

domain.com
domain2.com
domain3.com
...
domain100.com


I need to add domain101.com contained in $new_domain at the end of file

so I can have
domain.com
domain2.com
domain3.com
...
domain100.com
domain101.com

I am trying this



$file = "/usr/local/test.txt";
if (!file_exists("/usr/local/test.txt")) touch("/usr/local/test.txt");
$fh = fopen("/usr/local/test.txt", "r");
$fcontent = fread($fh, filesize("/usr/local/test.txt"));

$towrite = "$new_domain $fcontent";

$fh22 = fopen('/usr/local/test.txt', 'w+');
fwrite($fh2, $towrite);
fclose($fh);
fclose($fh2);



it doesn't work , it only create a blank file .

Is there a better way ?

SeeIT Solutions
11-22-2006, 01:25 AM
$fh22

$fh2

You're using incorrect variable names.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum