Jump to content

fwrite problems


dennismonsewicz

Recommended Posts

I am trying to write some test content to my CSV file and when I run my script everything seems to work properly but when I view the file nothing is in the CSV doc.

 

Code:

<?php

$file = 'file.csv';
$somecontent = "Hello World";

if(is_writable($file)) {
$fp = fopen($file, 'w');

if (!$handle = fopen($file, 'a')) {
         echo "Cannot open file ($filename)";
         exit;
    }

    // Write $somecontent to our opened file.
    if (fwrite($handle, $somecontent) === FALSE) {
        echo "Cannot write to file ($filename)";
        exit;
    }

fclose($fp);
echo 'Hello World';
} else {
echo 'File not writable';
}

?>

Link to comment
https://forums.phpfreaks.com/topic/184557-fwrite-problems/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.