Good morning Eve!
Sorry it has taken me so long to answer.
1: This is normal behavior. Your confusion here is thinking that an
auto_increment field is a record number.. It's not. It's simply a counter.
It does not ensure that you always have a contiguous sequence of numbers
starting form 1. It just makes sure that each record has it's own number.
2: This is the way that browsers work. If you use your back button, and you
got to the previous page by submitting a form then (at least IE) will make
you resubmit the form. If that form is populating a database blindly (no
checks to see if the data already exists) then it will insert a new record
into the table. It's just one of the small things that make our lives rough.
:)
Sorry I didn't have better answers for you. Best of luck in learning
PHP/MySQL. Don't be a stranger on the list.
HTH,
Cal
http://www.calevans.com
-----Original Message-----
From: Eve Edelson [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, March 27, 2001 6:15 PM
To: [EMAIL PROTECTED]
Subject: duplicate records, auto-increment problems, question
I am starting out to learn database scripting using PHP/mySQL/Apache on
Win98:
Apache 1.3.14(Win32) with PHP 4.04pl1
MySQL 3.23.28-gamma, localhost via TCP/IP
As an exercise I wrote a php script which dumps the contents of a
form into a database, prints the contents of the table (most recent
entry first) and repeats the form above those entries. It works but
there are 2 odd side effects.
1. refusal to reset record number
I filled out the form a number of times and the table became
properly populated. Satisfied it was working (ha!), I deleted the
trial data. When I started entering more data, new records no longer
started with record number 1. Record number is defined as not null,
auto increment & is the primary key. The record numbers don't reset
themselves although the table has been emptied. So the first record I
entered after emptying the table had record number 17, or something
like that. I tried forcibly setting the record number to 1 using
update, no luck.
2. duplicate records on page reload: only with Windows browser (IE and NN)
If I fill out the form and submit, the page goes away and if
I want to go back to the form and enter more data, I get a dialog box
saying I must reload the form. This is intermittent - it was doing it
yesterday, not today, and only using the Win98 browser (both IE and
NN) - doesn't happen with my Mac browser. If I do that, the previous
data is automatically re-entered, i.e., a duplicate new record goes
into the table, although I have not re-entered that data in the form.
The act of re-loading the form seems to duplicate the previous entry.
I can make it happen today, by deliberately refreshing the page.
The first symptom seems a mySQL one. Not sure about #2, sorry if it's
off-topic.
Not sure the script is the cause of all this, but will post if you
think it's relevant.
Thank you all for your time.
Eve
---------------------------------------------------------------------
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)
To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
---------------------------------------------------------------------
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)
To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php