funny problem

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
(1) I have about 8-9 .php files which are far from complex. I first
used GET in all of them. Worked fine. Then I changed all method="get"
to method="post" and $_GET to $_POST with search-replace, thinking that
it should work, but, it seems the $_POST variables are not getting
populated. Then I tried a simple one-page script using post - works
fine. So what could be the problem? I am not using
import_request_variables() or any such advanced feature.

(2) How do you address the situation where you have several
simultaneous users of your web application and your script reads from
the same single file, and maybe writes to the same single file(keep
aside the case of poor design, I am talking of say a page hit counter,
or reading initial settings from the single file), will not several
copies of your code in memory reading the same file on disk cause
problems? is there some specific code for such a situation? I looked
for "threadsafe" and "multiple user" but could not get anything.

Any help is appreciated.
Joseph S.

Re: funny problem

Hash: SHA1

Joseph S. napisał(a):
Quoted text here. Click to load it

Maybe you using something like:

echo "<a href=\"index?a=$a\">text</a>";

This is works only with $_GET.

Tom Wysocki
Version: GnuPG v1.4.1 (GNU/Linux)


Re: funny problem

Joseph S. wrote:
Quoted text here. Click to load it

Do you submit the forms or do you build up a query portion of a URL? The  
post method needs a <FORM> tag with form elements. It should be  
submitted. With the get method, you can just call a URL with a query  

Quoted text here. Click to load it
There are database servers that have addressed the locking and  
multi-user problems for you and there are also free webcounters  
available on the web. But if you want to do it with a file, you could  
try to achieve a file lock. Depending on the OS, you could either  
directly lock the file or work with a separate lockfile. Both have the  
disadvantage that if anything goes wrong, the counter file remains  
locked until you unlock it by hand.
An alternative approach is to run an external application (by using COM  
on Windows, for example) that is the only process to touch the file.  
Your PHP scripts can then call the external application for both reading  
and writing.

Best regards

Re: funny problem

Hash: SHA1

Joseph S. wrote:

Quoted text here. Click to load it

Seems like the same old reader-writer concurrency problem. Use some method
to lock the files, in order to avoid multiple writes. See .

- --  
- ----------------------------------
Iván Sánchez Ortega -i-punto-sanchez--arroba-mirame-punto-net

Los verdaderos programadores no trabajan de 9 a 6. Si puede verse alguno a
las 9, es porque ha estado toda la noche trabajando.
Version: GnuPG v1.4.2 (GNU/Linux)


Re: funny problem

Joseph S. wrote:
Quoted text here. Click to load it

Some typo somewhere...  Say, you now have $POST or $_POTS instead of

Quoted text here. Click to load it

Reading from the same file on a modern operating system should
require no attention at all; it is handled on the OS level.
Writing... well, read up on flock() and see what the manual has
to say about OS-specific details...

Quoted text here. Click to load it

Thread is a Windows-only concept.  On Unix, there are no threads,
only full-blown processes, each with a distinct ID...  This is
why file locking would work on Unix, but not on Windows...  


Re: funny problem

Why not use $_REQUEST?

Re: funny problem

It was not typos or urls with "name.php?q=whatever", it was the form
tag attribute enctype="text/plain" -
it was inserted by default in the form tag that is generated by
when you select the form option for post from the popup dropdown:

  <form action="link" method="post" enctype="text/plain">

It does not work with POST but works with GET.
(which is why the fact that it is part of the default text for the form
post tag in PHPEclipse comes as a surprise - it does not work - I have
XAMPP installed Apache/2.0.54 PHP/5.0.4 )

What I found is that with post, the enctype attribute
must either be omitted completely:
<form action="myform.php" method="post">
if specified, must be set to
enctype="application/x-www-form-urlencoded" or
which work.

As for concurrent file access, as Dikkie pointed out,
it is better to use a database
and if only read is involved, the OS should takes care of it.

I read and it seems better to use a database, however

Thanks all,

Site Timeline