You are here: Re: Re-opening a file « PHP Programming Language « IT news, forums, messages
Re: Re-opening a file

Posted by W Marsh on 07/15/07 13:57

On 15 Jul, 14:41, Jerry Stuckle <jstuck...@attglobal.net> wrote:
> W Marsh wrote:
> > Hi. In my application I do something very simple - I open a file, lock
> > it exclusively, write some data to it and close it.
>
> > If I re-open it in the same process (I mean before the script has
> > ended) to read the file, I find that the data I have written doesn't
> > exist in there. I can't read it back until I run the script again.
>
> > My question follows: WHAT
>
> Sorry, my crystal ball is in the shop. I have no idea what might be
> happening. Maybe if you post your code...
>
> --
> ==================
> Remove the "x" from my email address
> Jerry Stuckle
> JDS Computer Training Corp.
> jstuck...@attglobal.net
> ==================

No. For one thing it's private, commercial code, and secondly, I've
given enough information about the problem.

I don't appreciate people making sarcastic comments like that. If you
have no idea about the problem then keep quiet, or if you genuinely
are missing important details, make a polite request, e.g. "Are you
doing X between closing and re-opening the file?". I'm not an outlet
for problems with your insecurities and ego.

If you really are that unimaginative, then here's some code (using my
own original description as a design spec, proving my point somewhat):

define(FILE_NAME, "somefile.txt");

$dataOrig = array("here", "is", "some", "data", "to", "be",
"serialized");

$file = fopen(FILE_NAME, "w");
flock($file, LOCK_EX);
fwrite($file, serialize($dataOrig));
fclose($file);

$file = fopen(FILE_NAME, "r");
$dataNew = unserialize(fread($file, filesize(FILE_NAME)));

print_r($dataNew); // Expected output: Array ( [0] => here [1] => is
[2] => some [3] => data [4] => to [5] => be [6] => serialized )

It is not representative of the original code in terms of design or
error checking, but it does reproduce the problem on the production
server (no output, due to getting no data in the original file). It
does however run correctly on a my own web server, which suggests the
problem is one of configuration that somebody with experience in this
field could shed some light on, which I would be grateful for.

Do you see?

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация