473,385 Members | 1,622 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

using file_put_contents from pear

Hello!

We are running php 4.3.10

Therefore I need to use php_put_contents through
pear.

Thats what my file looks like:
<?php
require_once 'php/Compat/Function/file_put_contents.php';
$i=0;
while ($i <= 5){
$myArray[$i]="element position $i";
print("dollar-i er nå lik $i<br>\n" );
$i= $i + 1;
}
file_put_contents("array.txt", $myArray);
?>
Im not sure this is related to using a pear version or not, but I get a
Warning: file_put_contents() failed to open stream: Permission denied

Greatful to any clues!

Thanks!!

Jul 17 '05 #1
4 2410
Michael Preminger wrote:
Im not sure this is related to using a pear version or not, but I get
a Warning: file_put_contents() failed to open stream: Permission
denied


The dir/file must be writeable for Apache. Chmod the dir/file to 777 or make
Apache the owner to accomplish this (Note: don't use PHP's chmod() function
for this, but login to the server with FTP/SSH and peform the modification
through the client.
JW


Jul 17 '05 #2
On 23.01.2005 23:05, Janwillem Borleffs wrote:
Michael Preminger wrote:
Im not sure this is related to using a pear version or not, but I get
a Warning: file_put_contents() failed to open stream: Permission
denied

The dir/file must be writeable for Apache. Chmod the dir/file to 777 or make
Apache the owner to accomplish this (Note: don't use PHP's chmod() function
for this, but login to the server with FTP/SSH and peform the modification
through the client.
JW

Thank you!

Writing a file is now possible.
I am able to write a file to a special directory that apache may write to.

I actually wish to do the following:
read a text file with the file() function into a text array,
append a line to the array,
and write back using file_put_contents() into the same file.

this fails.

Is the error due to the file not being "closed" after being read by the
file() function?

Thanks
a lot!

Michael
Jul 17 '05 #3
Michael Preminger wrote:
I actually wish to do the following:
read a text file with the file() function into a text array,
append a line to the array,
and write back using file_put_contents() into the same file.

this fails.

Is the error due to the file not being "closed" after being read by
the file() function?


Which error do you get? Normally, the following should work fine:

$file = file($filename);
$file[] = "a line\n";
file_put_contents($filename, implode("", $file));
JW

Jul 17 '05 #4

Sorry to have bothered you. It was a simple file-access related problem.

On 26.01.2005 00:07, Janwillem Borleffs wrote:
Michael Preminger wrote:
I actually wish to do the following:
read a text file with the file() function into a text array,
append a line to the array,
and write back using file_put_contents() into the same file.

this fails.

Is the error due to the file not being "closed" after being read by
the file() function?

Which error do you get? Normally, the following should work fine:

$file = file($filename);
$file[] = "a line\n";
file_put_contents($filename, implode("", $file));
JW

Jul 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: DJ Majestik | last post by:
OK, I am new to the whole PEAR/Smarty templating thing. I am trying to setup my directory structure correctly. If someone could weigh in and see if I have this setup "right", I would appreciate it....
3
by: David | last post by:
I installed the Pear program and set the include path in php.ini to point to the pear dir. I have a program which <? require_once("DB.php"); ?> This produces the error "Class 'PEAR_Error'...
2
by: Alan Prescott | last post by:
I'm running SuSE Linux 9.3, fully up to date running # pear install db responds with ... downloading DB-1.7.6.tgz ... Starting to download DB-1.7.6.tgz (124,807 bytes)...
5
by: Jim Michaels | last post by:
I downloaded a PEAR module, but it came with this XML file and a PHP file. I figure I just include the PHP file somehow, but what do I do with the XML file?
1
by: IchBin | last post by:
I remember having problems with pear when I first installed it but got it running some time ago. This is on a windoze XP SP OS. I did not think it was correct because it pointed to...
7
by: amygdala | last post by:
Hi, I'm trying to let PHP write a 'sitemap.xml' sitemap for Google and other searchengines. It's working, except that the content in the XML file doesn't seem to be UTF8. (Which it should be,...
9
moishy
by: moishy | last post by:
When I try to write to file like this: file_put_contents("test.txt","Hello World"); I get an error: Fatal error: Call to undefined function: file_put_contents() File_get_contents works...
5
by: ^AndreA^ | last post by:
Hello everybody, I'm trying to get a file on the internet and put it on my server... So, from javascript (AJAX) a call a php function that is simply: file_put_contents('RSS_news/bbc.xml',...
9
by: pavanponnapalli | last post by:
hi, i have data as under. 127.0.0.1 - - "GET /favicon.ico HTTP/1.1" 404 292 127.0.0.1 - - "GET /favicon.ico HTTP/1.1" 404 292 127.0.0.1 - - "GET /pear/symfony/ HTTP/1.1" 404 294...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.