ASP, CGI and PHP Scripts and Record-Locking: What Every Webmaster Needs To Know - There are a...
(Page 3 of 7 )
3. There are a number of ways things can now go wrong, for
(a) What if the first copy of the script reads in the data, then
the second copy reads the same data, then the first copy updates
the data, then the second copy updates the data? Answer: any
changes made by the first copy of the script can get lost.
(b) What if the first and second copy of scripts are both adding
multiple bits of new data to the store at the same time? For
example, imagine each needs to store the headline, description
and the name of the person posting a classified ad. Well, what
can happen (with some scripts) is the two classified ads can get
intermingled, so you might get (for example) HEADLINE-1,
DESCRIPTION-1, HEADLINE-2, PERSON-1, DESCRIPTION-2, PERSON-2.
Or worse yet, you might get bits of each part of each classified
ad, mixed with the bits of the other. This type of thing is
usually really bad news, as your data may consequently becoming
unusable from that point on.
Does this sound too unlikely a problem to worry about? Don't bank
on it... even if it happens only 1 time in 1,000, or 1 in 10,000,
eventually it will happen: You need a solution.
So the real question is: is it possible for programmers to create
scripts without these kinds of problems? Fortunately the answer
is yes, and there are a number of ways that programmers can
More Website Content Articles
More By Jase Dow