Beater
Beater

Reputation: 121

Add a line to a file using fwrite

Ive been trying to work this out:

if(isset($_POST['server'])):
    $block = $_POST['ip'];
    $file_handle = fopen($file, "a+");
    $content = "\n" . $block;
    fwrite($file_handle, $content);
    fclose($file_handle);
endif;

just doesnt write it in the file. I do have the $file stated.

Upvotes: 0

Views: 53

Answers (1)

avrono
avrono

Reputation: 1680

Put a check in to see if the fopen is successful

if($filehandle) {
    // do something
}

I suspect you will find that the file is not open

Upvotes: 1

Related Questions