Re: incrementing a number from a text file

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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


"Kim Madsen" <km@xxxxxxx> wrote in message 
news:15653CE98281AD4FBD7F70BCEE3666E51C2B23@xxxxxxxxxxxxxxxxxxxxxxxx

-----Original Message-----
From: Richard Lynch [mailto:ceo@xxxxxxxxx]
Sent: Thursday, March 10, 2005 10:14 PM
To: Ross Hulford
Cc: php-general@xxxxxxxxxxxxx
Subject: Re:  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 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux