alexander-fire
alexander-fire

Reputation: 1082

PHP write in file

I want to write something in a textfile.

$myFile = "meinung.txt";
$fh = fopen($myFile, 'w') or die("can't open file");
$stringData = "Floppy Jalopy\n";
fwrite($fh, $stringData);
$stringData = "Pointy Pinto\n";
fwrite($fh, $stringData);
fclose($fh);

when i want to execute this, it says "cant open file"

what did i make wrong?

Upvotes: 0

Views: 283

Answers (1)

initall
initall

Reputation: 2385

Place

<?php
error_reporting(E_ALL);
ini_set('display_errors','On');
...

on top of your code to get error messages on screen or in your logfile (You know where your error logfile is, don't you?).

Set an absolute path to your file so that you really know in what directory the file is actually created to fix the filesystem permissions as noted in the comments.

Upvotes: 1

Related Questions