Reply to Re: [PHP] incrementing a number from a text file

Your name:

Reply:


Posted by Ross Hulford on 10/16/57 11:10

I am just going to adda auto incrementing DB filed and get the numbers that
way. Seems the best way.


"Kim Madsen" <km@comx.dk> wrote in message
news:15653CE98281AD4FBD7F70BCEE3666E51C2B23@comxexch01.comx.local...

-----Original Message-----
From: Richard Lynch [mailto:ceo@l-i-e.com]
Sent: Thursday, March 10, 2005 10:14 PM
To: Ross Hulford
Cc: php-general@lists.php.net
Subject: Re: [PHP] incrementing a number from a text file

>> I want to read a number from an external (txt) file and increment it.then
>> save the number back on the text file.
>> I know this is possible but want a simple amd economical way to do this.

> That's what you *THINK* you want to do :-)

> But what happens when *TWO* users hit that same script at exactly the same
> time.

<snip>

> This is why so many early "hit counter" scripts back in the day were
> always getting messed up and reset to 0.

Don΄t increase if counter is not read?

> What you really want, almost for sure, is an SQL database with "sequences"

I try NOT to use databases if not nessecary

> You *can* use http://php.net/flock, but even that is a Bad Idea, because
> flock under Un*x is self-imposed -- If some *other* program/script/user
> decides not change that file and doesn't use flock, well, they're not
> STOPPED from doing that.

Poor programming?

> flock is therefore all too subject to human fallibility when you re-work,
> re-write, or add more code to your system.

Every code is... if You don΄t use Your head, the outcome will be...?

If U no nothing about SQL, I use a database to a counter, I get a piece of
code from a friend "alter table counter auto_increment = 1"; and I΄m curious
to see, what it does?

Or better: I put my query in a link like <a
href="db.php?q=select+*+from+customers">show customers</a> and I΄ve got NO
clue about the settings in the mysql db, so this gets "funny"
<a href="db.php?q=delete+from+customers">show customers</a>
<a href="db.php?q=drop+table+customers">show customers</a>

*whistle*

This _was_ an issue in a company I worked for, along with queries like:

Select blablabla FROM t1,t2,t3
WHERE customers LIKE '%$s%'
OR name LIKE '%$s%'
OR domain LIKE '%$s%'
OR email LIKE '%$s%'
OR log LIKE '%$s%'
AND t1.id = t2.t1_id
AND t1.id = t3.t1_id

Horror!

Kind regards
Kim Madsen

[Back to original 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

Π‘Π°ΠΉΡ‚ ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ Π² Π‘Ρ‚ΡƒΠ΄ΠΈΠΈ Π’Π°Π»Π΅Π½Ρ‚ΠΈΠ½Π° ΠŸΠ΅Ρ‚Ρ€ΡƒΡ‡Π΅ΠΊΠ°
ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ΠΈΠ΅ ΠΈ ΠΏΠΎΠ΄Π΄Π΅Ρ€ΠΆΠΊΠ° Π²Π΅Π±-сайтов, Ρ€Π°Π·Ρ€Π°Π±ΠΎΡ‚ΠΊΠ° ΠΏΡ€ΠΎΠ³Ρ€Π°ΠΌΠΌΠ½ΠΎΠ³ΠΎ обСспСчСния, поисковая оптимизация