fopen PHP failing on Ubuntu 10.10
Posted: Thu Apr 14, 2011 12:27 pm
hello guys..I dont know whether this is right place to post this question. I recently installed LAMP on my ubuntu 10.10 (which is fine) and tried to write a simple php program which writes hello world in it. Then I placed this file in /var/www and using firefox ran the code. Here is what it looks like
But this shows error ..."Unable to open file". Whats the problem with code or any configuration that I am missing.
Code: Select all
<?php
$file_name = "home/muze/Example.txt"; //also tried [i]$file_name = "Example.txt";[/i] but in vain
$text = "Muzammil";
$file = fopen($file_name, "w") or die('Unable to open file');
fwrite($file, $text) or die('Unable to write text');
$contents = file_get_contents($file) or die('Unable to get contents');
echo $contents;
fclose($file);
?>