RE: [PHP-DB] finding out the result of an INSERT

2001-07-10 Thread Michael Rudel

RTFM or search in the archive of this mailinglist !!!

int mysql_insert_id ([int link_identifier])

Greetinx,
  Mike

Michael Rudel
- Web-Development, Systemadministration -

Besuchen Sie uns am 20. und 21. August 2001 auf der
online-marketing-düsseldorf in Halle 1 Stand E 16
___

Suchtreffer AG
Bleicherstraße 20
D-78467 Konstanz
Germany
fon: +49-(0)7531-89207-17
fax: +49-(0)7531-89207-13
e-mail: mailto:[EMAIL PROTECTED]
internet: http://www.suchtreffer.de
___



 -Original Message-
 From: Cable, Christian [mailto:[EMAIL PROTECTED]]
 Sent: Tuesday, July 10, 2001 12:52 PM
 To: [EMAIL PROTECTED]
 Subject: [PHP-DB] finding out the result of an INSERT


 Hi,

 this might be a stupid question but it's got me stumped today

 My setup: php, mysql, apache etc

 I'm inserting a record into a table that's got a primary key
 which is auto
 incrementing ..

 +---+---+--+-+-+--
 --+
 | Field | Type  | Null | Key | Default |
 Extra  |
 +---+---+--+-+-+--
 --+
 | message_id| int(11)   |  | PRI | NULL|
 auto_increment |
 | message_text  | mediumtext| YES  | | NULL|
   |
 | topic_id  | int(11)   | YES  | | NULL|
   |
 | user_id   | int(11)   | YES  | | NULL|
   |
 | message_title | varchar(50)   | YES  | | NULL|
   |
 | message_time  | timestamp(14) | YES  | | NULL|
   |
 | parent_id | int(11)   | YES  | | NULL|
   |
 | thread_id | int(11)   | YES  | | NULL|
   |
 +---+---+--+-+-+--
 --+

 by doing

 $sql = INSERT INTO messagetable(user_id, message_title,
 message_text,topic_id,
 thread_id, parent_id) VALUES
 ('$userid','$subject','$comment','$topic_id','$thread_id','$pa
 rent_id');
 mysql_query($sql);

 which works fine BUT is there any way of finding out the
 message_id of the
 record I just inserted ?

 with thanks

 Christian


 Christian Cable
 ICT Assistant
 Careers Service; Lancaster University
 Tel: (01524) 594072  Fax: (01524) 592072
 http://www.lancs.ac.uk/staff/cable/



 --
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail:
 [EMAIL PROTECTED]



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] finding out the result of an INSERT

2001-07-10 Thread Roger Ramirez

http://php.net/manual/en/function.mysql-insert-id.php

 from the link above 
Warning:
mysql_insert_id() converts the return type of the native MySQL C API
function mysql_insert_id() to a type of long. If your AUTO_INCREMENT column
has a column type of BIGINT, the value returned by mysql_insert_id() will be
incorrect. Instead, use the internal MySQL SQL function LAST_INSERT_ID().


- Original Message -
From: Cable, Christian [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Tuesday, July 10, 2001 6:51 AM
Subject: [PHP-DB] finding out the result of an INSERT


 Hi,

 this might be a stupid question but it's got me stumped today

 My setup: php, mysql, apache etc

 I'm inserting a record into a table that's got a primary key which is auto
 incrementing ..

 +---+---+--+-+-++
 | Field | Type  | Null | Key | Default | Extra  |
 +---+---+--+-+-++
 | message_id| int(11)   |  | PRI | NULL| auto_increment |
 | message_text  | mediumtext| YES  | | NULL||
 | topic_id  | int(11)   | YES  | | NULL||
 | user_id   | int(11)   | YES  | | NULL||
 | message_title | varchar(50)   | YES  | | NULL||
 | message_time  | timestamp(14) | YES  | | NULL||
 | parent_id | int(11)   | YES  | | NULL||
 | thread_id | int(11)   | YES  | | NULL||
 +---+---+--+-+-++

 by doing

 $sql = INSERT INTO messagetable(user_id, message_title,
message_text,topic_id,
 thread_id, parent_id) VALUES
 ('$userid','$subject','$comment','$topic_id','$thread_id','$parent_id');
 mysql_query($sql);

 which works fine BUT is there any way of finding out the message_id of the
 record I just inserted ?

 with thanks

 Christian


 Christian Cable
 ICT Assistant
 Careers Service; Lancaster University
 Tel: (01524) 594072  Fax: (01524) 592072
 http://www.lancs.ac.uk/staff/cable/



 --
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]




-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]