473,385 Members | 1,647 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.

file locking

I am new to php and am on chapter 2 PHP and MySQL by Welling and Thomson.

When executing the code from the example to write the output data string:

// open file for appending
@ $fp = fopen("../../orders/orders.txt", "a");

flock($fp, 2);

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, $outputstring);
flock($fp, 3); //line 56
fclose($fp);

The processorder.php page opens and the screen output is ok. Then I get the
following message below the order echos:

Warning: flock(): supplied argument is not a valid stream resource in
c:\inetpub\wwwroot\phptest\PROCESSORDER.PHP on line 56

Any advice of where I might find information on why I get this message will
be appreciated.

Bert


Jul 17 '05 #1
3 1576
Sorry, the error occured on the first call to flock as indicated below.
"Bert" <be*********@meckcom.net> wrote in message
news:C4******************@fe07.usenetserver.com...
I am new to php and am on chapter 2 PHP and MySQL by Welling and Thomson.

When executing the code from the example to write the output data string:

// open file for appending
@ $fp = fopen("../../orders/orders.txt", "a");

flock($fp, 2);

if (!$fp) //line 56
{
echo "<p><strong> Your order could not be processed at this time. "
."Please try again later.</strong></p></body></html>";
exit;
}

fwrite($fp, $outputstring);
flock($fp, 3);
fclose($fp);

The processorder.php page opens and the screen output is ok. Then I get the following message below the order echos:

Warning: flock(): supplied argument is not a valid stream resource in
c:\inetpub\wwwroot\phptest\PROCESSORDER.PHP on line 56

Any advice of where I might find information on why I get this message will be appreciated.

Bert



Jul 17 '05 #2
jn
"Bert" <be*********@meckcom.net> wrote in message
news:C4******************@fe07.usenetserver.com...
I am new to php and am on chapter 2 PHP and MySQL by Welling and Thomson.

When executing the code from the example to write the output data string:

// open file for appending
@ $fp = fopen("../../orders/orders.txt", "a");

flock($fp, 2);

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, $outputstring);
flock($fp, 3); //line 56
fclose($fp);

The processorder.php page opens and the screen output is ok. Then I get the following message below the order echos:

Warning: flock(): supplied argument is not a valid stream resource in
c:\inetpub\wwwroot\phptest\PROCESSORDER.PHP on line 56

Any advice of where I might find information on why I get this message will be appreciated.

Bert


That error means the file couldn't be opened.

Put that flock() after your if(!$fp) block, and you will probably see your
custom error message.
Jul 17 '05 #3

"jn" <us********************************@jasonnorris.ne t> wrote in message
news:R%*********************@twister.tampabay.rr.c om...
"Bert" <be*********@meckcom.net> wrote in message
news:C4******************@fe07.usenetserver.com...
I am new to php and am on chapter 2 PHP and MySQL by Welling and Thomson.


When executing the code from the example to write the output data string:

// open file for appending
@ $fp = fopen("../../orders/orders.txt", "a");

<snip>
The processorder.php page opens and the screen output is ok. Then I get

the
following message below the order echos:

Warning: flock(): supplied argument is not a valid stream resource in
c:\inetpub\wwwroot\phptest\PROCESSORDER.PHP on line 56

Any advice of where I might find information on why I get this message

will
be appreciated.

Bert


That error means the file couldn't be opened.

Put that flock() after your if(!$fp) block, and you will probably see your
custom error message.


You're using a relative path, so you might like to check where you are - you
might be surprised. Also check file/directory permissions - your web server
account needs to be able to access the file.

Garp
Jul 17 '05 #4

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

Similar topics

18
by: Dino | last post by:
dear all, i've created an application for a customer where the customer can upload ..csv-files into a specified ftp-directory. on the server, a php-script, triggered by a cronjob, reads all the...
2
by: Kamus of Kadizhar | last post by:
Thanks to Robert Brewer, I got enough insight into logging to make it work.... Now I have another issue: file locking. Sorry if this is a very basic question, but I can't find a handy reference...
2
by: Corne' Cornelius | last post by:
Hi, When you open a file for writing/appending with open() or fopen(), and you have multiple applications that might want to write to the same file at the same time, could that cause weirdness...
8
by: Stephen Corey | last post by:
I'm writing an app that basically just appends text to a text file on a Win2K Server. They fill out a form, click a button, and 1 line is appended to the file. Multiple people will run this app at...
4
by: darrel | last post by:
I've been dealing with a file locking issue for a while. Our CMS spits out a new XML file each time an item in the DB is updated. This XML file is basically our site menu, and is what we use on...
1
by: ABCL | last post by:
Hi All, I am working on the situation where 2 different Process/Application(.net) tries to open file at the same time....Or one process is updating the file and another process tries to access...
13
by: George | last post by:
Hi, I am re-writing part of my application using C#. This application starts another process which execute a "legacy" program. This legacy program writes to a log file and before it ends, it...
17
by: shineofleo | last post by:
Here is the situation: I wrote a VB programm, which stores all the information in a single Access database file using jet engine. It worked well, however one of my customs reported that there was...
15
by: Amir Michail | last post by:
Hi, Trying to open a file for writing that is already open for writing should result in an exception. It's all too easy to accidentally open a shelve for writing twice and this can lead to...
15
by: Matt Brandt | last post by:
I am trying to get multiple threads to lock specific regions of a file. However, since each thread has the same PID, it appears that a lock by one thread does not block another thread from the same...
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
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:
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?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.