By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,278 Members | 1,358 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,278 IT Pros & Developers. It's quick & easy.

Serial key in Mysql

P: n/a
Hi,
can anyone tell me how I can automaticly generate a serial key? - I
get an error message, when I don't provide a number for the id in the
example below. A NULL value doesn't work either.
Thank you very much for any hint.

CREATE TABLE user
(USER_ID BIGINT UNSIGNED NOT NULL AUTO_INCREMENT UNIQUE,
USER_NAME varchar(10) NOT NULL,
LAST_NAME varchar(30),
FIRST_NAME varchar(30),
E_MAIL varchar(30),
M_PHONE varchar(15),
PRIMARY KEY (USER_ID)
);

$query = "INSERT INTO user (USER_ID, USER_NAME, LAST_NAME, FIRST_NAME,
E_MAIL, M_PHONE) VALUES
( $id, " .
"\"" . $nick . "\", " .
"\"" . $nachname . "\", " .
"\"" . $vorname . "\", " .
"\"" . $email . "\", " .
"\"" . $handy . "\")";
Jul 17 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Heinz wrote:
can anyone tell me how I can automaticly generate a serial key? - I
get an error message, when I don't provide a number for the id in the
example below. A NULL value doesn't work either.
Thank you very much for any hint.


USER_ID INT(11) AUTO_INCREMENT

JW

Jul 17 '05 #2

P: n/a
Janwillem Borleffs wrote:
USER_ID INT(11) AUTO_INCREMENT


Additionally:

$query = "INSERT INTO user (USER_NAME, LAST_NAME[,...]

(So, don't assign a value to USER_ID. Let MySQL handle this)
JW

Jul 17 '05 #3

P: n/a
On Sun, 4 Jul 2004 13:12:34 +0200, "Janwillem Borleffs"
<jw@jwscripts.com> wrote:
Janwillem Borleffs wrote:
USER_ID INT(11) AUTO_INCREMENT


Additionally:

$query = "INSERT INTO user (USER_NAME, LAST_NAME[,...]

(So, don't assign a value to USER_ID. Let MySQL handle this)


If you're not explicitly populating fields, you still need to have a
placeholder for it. If it's the first field in the table,

insert into user ( 0, 'USER_NAME', 'USER LAST NAME'. ....) will get it
right.
--
gburnore@databasix dot com
---------------------------------------------------------------------------
How you look depends on where you go.
---------------------------------------------------------------------------
Gary L. Burnore | ۳ݳ޳ݳۺݳ޳ݳݳ޳ݳ۳
| ۳ݳ޳ݳۺݳ޳ݳݳ޳ݳ۳
DataBasix | ۳ݳ޳ݳۺݳ޳ݳݳ޳ݳ۳
| ۳ 3 4 1 4 2 ݳ޳ 6 9 0 6 9 ۳
Black Helicopter Repair Svcs Division | Official Proof of Purchase
================================================== =========================
Want one? GET one! http://www.databasix.com
================================================== =========================
Jul 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.