file_put_contents NOT working using LAMP (ubuntu 10.10)

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
muze
Forum Newbie
Posts: 2
Joined: Thu Apr 14, 2011 12:14 pm

file_put_contents NOT working using LAMP (ubuntu 10.10)

Post by muze »

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

Code: Select all

<?php
        file_put_contents('home/muze/Example.txt','This is in file.') or die('Unable to open file');
?>
 
But this shows error ..."Unable to open file". Whats the problem with code or any configuration that I am missing.
User avatar
Darhazer
DevNet Resident
Posts: 1011
Joined: Thu May 14, 2009 3:00 pm
Location: HellCity, Bulgaria

Re: file_put_contents NOT working using LAMP (ubuntu 10.10)

Post by Darhazer »

Maybe you wanted it to be '/home/muze/Example.txt' (otherwise the path is relative to the current path)
fugix
Forum Contributor
Posts: 207
Joined: Fri Mar 18, 2011 8:01 pm

Re: file_put_contents NOT working using LAMP (ubuntu 10.10)

Post by fugix »

take out the die() function and put

Code: Select all

print_r(error_get_last());
at the end of your code and post the results please
Post Reply