Forum Moderators: coopster

Message Too Old, No Replies

MySQl Autnumber problems

forms, autonumber

         

aditogs

3:56 pm on Feb 9, 2007 (gmt 0)

10+ Year Member



I am posting the details of my form to a database. The fields are name, email and comment. It may be that they contact me through the form more than once, so my MySql key can't be name or email.

I know you can get an autonumber lookup for MySql so that the form details get pushed onto the next free space (is it auto-incrementing?) and thats what I need. Does anyone know how to do it?

Alternatively, I thought I could use the date and time as the key, but the only format I know for the date and time is:

$todayis = date("l, F j, Y, g:i a") ;

which doesn't work as it brings up "Friday, February 9, 2007, 10:39 am [EST]" (Not a good key!) Does anyone know how to change the date= to make it usable as a key?

Thanks

dreamcatcher

4:23 pm on Feb 9, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi aditogs,

Yep, just use an auto increment field as you stated:


CREATE TABLE emaildata (
id int unsigned NOT NULL auto_increment,
email varchar(250) not null default '',
name varchar(250) not null default '',
PRIMARY KEY (id)
) TYPE=MyISAM;

Adjust to suit. Something like that maybe? Its easier when deleting info too as each id will be unique.

dc