file access problem

This is a discussion on "file access problem" within the PHP Forum section. This forum, and the thread "file access problem are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > PHP Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Jun 4th, 2006, 22:46
Junior Member
Join Date: Feb 2006
Location: West Yorks, UK
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Question file access problem

I'm going through the example in the book 'PHP & MySQL Web Development' by Luke Welling & Laura Thomson, and I've hit a problem in chapter 2!

It's to do with accessing files, which is as yet something I know very little about.

The code that was supplied with the book says this:

PHP: Select all

// open file for appending 


 
$fp fopen("$DOCUMENT_ROOT/../orders/orders.txt"'ab'); 
flock($fpLOCK_EX);  

if (!
$fp

    echo 
'<p><strong> Your order could not be processed at this time. ' 
    
.'Please try again later.</strong></p></body></html>'
    exit; 
}  

fwrite($fp$outputstringstrlen($outputstring)); 
flock($fpLOCK_UN);  
fclose($fp); 

echo 
'<p>Order written.</p>'
The error I get says this:

Warning: flock(): supplied argument is not a valid stream resource in /******/******/public_html/book/autoparts/02/processorder.php on line 67

Line 67 is the first flock.

I appreciate this is really a UNIX problem, but at this point I just want something to make this code work, so I can carry on learning about PHP and MySQL, rather than a detailed tangent about UNIX, which I intend to learn about later as a separate project.

Can anybody help, please?

I am running this on a remote server, not my own machine. The PHP and HTML files are all in ~/public_html/book/autoparts/02/.
Reply With Quote

  #2 (permalink)  
Old Jun 5th, 2006, 01:43
Most Reputable Member
Join Date: Aug 2005
Location: North Wales, United Kingdom
Age: 21
Posts: 1,093
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to sypher
Re: file access problem

Makesure you have CHMOD the directory its talking about.

(Open ur ftp locate the directory right click CHMOD)
It may be slightly different with assorted FTP programs.
Reply With Quote
  #3 (permalink)  
Old Jun 5th, 2006, 08:22
Reputable Member
Join Date: Jul 2005
Location: Melksham, Wilts, UK
Posts: 293
Thanks: 0
Thanked 0 Times in 0 Posts
Re: file access problem

Yes, it's likely to be file permissions. The fopen is probably failing, but the @ character at the start of that line tells PHP to supress the error message if it has a problem. If you remove the @ for a test run, you'll see the real error and not the aftereffect with is the error reported by flock.

-- Graham
Reply With Quote
Reply

Tags
file, access, problem

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] sql file problem longstand Databases 1 Oct 27th, 2007 17:09
Access Denied Problem EdwardA Databases 3 Dec 27th, 2006 22:51
can several people access a file and use it ! rigidig ASP.NET Forum 2 Jul 19th, 2006 20:49
UPDATE information in access problem KingIsulgard Classic ASP 1 Jan 31st, 2006 13:09
Access Problem KingIsulgard Classic ASP 3 Jan 30th, 2006 20:27


All times are GMT. The time now is 20:46.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43