473,725 Members | 2,173 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

[function.file-put-contents]: failed to open stream

I'm trying to troubleshoot a membership script. The script is
attempting to write to a file called .fdaccess. The function that's
throwing the error is in a file called htpasswd.php. Here's the
fuinction:

function save($file=fals e){
$fcontents = "";
if($file == false) $file = $this->_path;
foreach(array_k eys($this->users) as $user){
$fcontents .= $user.":".$this->users[$user]."\n";
}
if(file_put_con tents($file, $fcontents)){
$this->error = '';
return true;
}else{
$this->error = 'Couln\'t save the file!';
return false;
}
}

Here's the error...

Warning: file_put_conten ts(/public_html/mylogins/extras/.fdaccess)
[function.file-put-contents]: failed to open stream: No such file or
directory in /home/freebnow/public_html/mylogins/admin/htpasswd.php on
line 111

This is line 111: if(file_put_con tents($file, $fcontents)){

htpasswd.php is a class available here: http://www.apachelounge.com/forum/viewtopic.php?t=635

The file is in the path specified, and it is chmod 700.

Any suggestions?

Aug 25 '08 #1
2 10098
webguy262 wrote:
I'm trying to troubleshoot a membership script. The script is
attempting to write to a file called .fdaccess. The function that's
throwing the error is in a file called htpasswd.php. Here's the
fuinction:

function save($file=fals e){
$fcontents = "";
if($file == false) $file = $this->_path;
foreach(array_k eys($this->users) as $user){
$fcontents .= $user.":".$this->users[$user]."\n";
}
if(file_put_con tents($file, $fcontents)){
$this->error = '';
return true;
}else{
$this->error = 'Couln\'t save the file!';
return false;
}
}

Here's the error...

Warning: file_put_conten ts(/public_html/mylogins/extras/.fdaccess)
[function.file-put-contents]: failed to open stream: No such file or
directory in /home/freebnow/public_html/mylogins/admin/htpasswd.php on
line 111

This is line 111: if(file_put_con tents($file, $fcontents)){

htpasswd.php is a class available here: http://www.apachelounge.com/forum/viewtopic.php?t=635

The file is in the path specified, and it is chmod 700.

Any suggestions?

What's the contents of $file?

--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===

Aug 25 '08 #2
webguy262 wrote:
I'm trying to troubleshoot a membership script. The script is
attempting to write to a file called .fdaccess. The function that's
throwing the error is in a file called htpasswd.php. Here's the
fuinction:

function save($file=fals e){
$fcontents = "";
if($file == false) $file = $this->_path;
foreach(array_k eys($this->users) as $user){
$fcontents .= $user.":".$this->users[$user]."\n";
}
if(file_put_con tents($file, $fcontents)){
$this->error = '';
return true;
}else{
$this->error = 'Couln\'t save the file!';
return false;
}
}

Here's the error...

Warning: file_put_conten ts(/public_html/mylogins/extras/.fdaccess)
[function.file-put-contents]: failed to open stream: No such file or
directory in /home/freebnow/public_html/mylogins/admin/htpasswd.php on
line 111

This is line 111: if(file_put_con tents($file, $fcontents)){

htpasswd.php is a class available here: http://www.apachelounge.com/forum/viewtopic.php?t=635

The file is in the path specified, and it is chmod 700.

Any suggestions?
chmod 700 isn't the right permissions unless PHP is running as the
same owner as the file to which you're attempting to write, which is
not always the case. If your script has to create the file, I believe
the directory needs write/execute privileges for the containing dir.

Try chmod 622 (gives write access to the world) or 666 (read and
write). You can amend .htaccess or httpd.conf (if available to you) to
forbid direct access to your file, which will work, regardless of file
permissions.

--
Curtis
Aug 25 '08 #3

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

Similar topics

3
2066
by: Cherrish Vaidiyan | last post by:
hello scholars, i am just learning PHP. i have a small requirement in urgency.i want to create a functionality of archiving in which a user can upload any file through a browser to a location. but in that functionality. I want to solve a small error in my program.The case is explained below.... If i type the path,currently my program dont check for existance of the file.ie; even if the file exist or not, the results appears as
2
1399
by: jon.berg | last post by:
I have a problem getting the file() function in PHP to work on several linux distributions, for example fedora core 3. For example file('http://someurl.com/') do not return the content of that page. This is when I use the version of Apache and PHP that comes with the operating system. When I compile Apache and PHP from source it works. Is there some configuration that can be done so it will work? I need to make it work on a server...
11
1972
by: Bryant Huang | last post by:
Hello! I would like to read in files, during run-time, which contain plain Python function definitions, and then call those functions by their string name. In other words, I'd like to read in arbitrary files with function definitions, using a typical 'open()' call, but then have those functions available for use. The 'import' keyword is not appropriate, AFAIK, because I want to be able to open any file, not one that I know ahead of...
3
3255
by: Susan | last post by:
Hi all, I have several books on Javascript and, although they mention placing frequently used script functions in a central file and calling them from, there they don't explain how to call them. Can someone explain how I can call separate functions from a .js file that contains several functions from different webpages as they are needed? I've tried to do on my own it with no success.
1
3676
by: kaiser | last post by:
Hello. I am trying to write a program that continues to read the last line of a txt file until a stop button is clicked. while (ContinueLoop == true ) { while ((LastLine = file.ReadLine()) != null) { LastLine = file.ReadLine(); }//while readline
6
4268
by: mygoogleaccount | last post by:
Hi, may be someone could help me ? i need to use cyrillic letters in a php application. I changed everything to UTF-8 and it works fine. The only problem are CYRILLIC SMALL LETTER ES CYRILLIC SMALL LETTER YA
2
1330
by: r.knipscheer | last post by:
Hi, i've written a function to check if an image on a server exists: i send the url to check to the function and check it with: $file = @file ($url); if ($file) { this works ok, as long as i use it on my computer. As soon as i upload it to my webserver this function won't work. Is this a known security
7
2276
by: danielbaars | last post by:
Hello, I'm almost a complete newbie to using PHP and I was hoping one of you guys can point me in the right direction. I'm working on a site for a brand of handmade fruit juice and it only needs one bit of dynamic content: the info on what fruit is in the juice and where it is coming from (vendor, country etc.) today and tomorrow (the content of the juice is different everyday). So I thought it would be easiest to put that information...
12
4560
by: snow | last post by:
Hi All, I noticed if file path has a white space, for example "C:\my document \test.txt", the function File.Exists(filePath) always return false in release mode. How could I make this function work for the file which is located in a direcotry with a white space? Thanks!
1
3883
by: faultykid | last post by:
I would like to store a variable then call it back later. I have a variable on line 198 www = ''+this._ad.clickUrl+''; and on line 321 i try document.write(www);
0
8888
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8752
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9401
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9257
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9113
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8097
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6011
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3221
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2157
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.