Re: determining the value of an auto-incremented field (mysql)

From: Date: Thu, 16 Aug 2001 18:08:15 +0000
Subject: Re: determining the value of an auto-incremented field (mysql)
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-11451@lists.php.net to get a copy of this message
Here is the page for the information on this function: http://www.php.net/manual/en/function.mysql-insert-id.php mysql_insert_id() being a function, the () after the name are necessary. HTH Maureen Kenn Murrah <webmaster@bakergrfx.com> said: > I'm sorry to be so obtuse, but I still don't get it ... > > I've tried: > > $sql = "INSERT INTO orders set products_ordered='$products', > ordered_by='$username', company='$company', > address_1='$address_1', > address_2='$address_2', city='$city', state='$state', > zip='$zip', > attn='$attn', special_instructions='$special_instructions', > shipping_instructions='$shipping_instructions', status='$status', > rush='$rush', date_ordered='$current_time' , > month_due='$month_due', > day_due='$day_due' > " ; > > $result = mysql_query($sql) or die("ERROR -- try again111111 or see Kenn > Murrah"); > > $order_number=mysql_insert_id; > > > .... and I'm still not getting a value for $order_number, the > auto-incremented value. > > I'm REALLY sorry to waste the list's time with this ... but I do appreciate > the help from all of you ... > > Kenn > > > ----- Original Message ----- > From: "Brunner, Daniel" <daniel.brunner@duni.com> > To: "'Kenn Murrah'" <webmaster@bakergrfx.com> > Cc: "PHP List (E-mail)" <php-db@lists.php.net> > Sent: Thursday, August 16, 2001 12:39 PM > Subject: RE: [PHP-DB] determining the value of an auto-incremented field > (mysql) > > > | Say... > | > | > | You can us it after you do your insert...then ....do something like..... > | > | echo ("<B>Your new Order Number is") . mysql_insert_id . > ("&nbsp;Please > | write this down</B>n"); > | > | Your whatever you want..... > | > | > | Dan > | > | > | > | > ---------- > | > From: Kenn Murrah > | > Sent: Thursday, August 16, 2001 12:29 PM > | > To: Brunner, Daniel > | > Subject: Re: [PHP-DB] determining the value of an > | > auto-incremented field (mysql) > | > > | > thanks, Dan ... i'll RTFM now to figure out exactly how to use it ... > | > > | > and thanks again for your prompt response ... > | > > | > Kenn > | > > | > > | > > | > ----- Original Message ----- > | > From: "Brunner, Daniel" <daniel.brunner@duni.com> > | > To: "'Kenn Murrah'" <webmaster@bakergrfx.com> > | > Sent: Thursday, August 16, 2001 12:25 PM > | > Subject: RE: [PHP-DB] determining the value of an auto-incremented > | > field > | > (mysql) > | > > | > > | > | Hello!! > | > | > | > | > | > | > | > | mysql_insert_id() > | > | > | > | > | > | Dan > | > | > | > | > | > | > | > | > ---------- > | > | > From: Kenn Murrah > | > | > Sent: Thursday, August 16, 2001 12:17 PM > | > | > To: php-db@lists.php.net > | > | > Subject: [PHP-DB] determining the value of an auto-incremented > | > | > field (mysql) > | > | > > | > | > Greetings: > | > | > > | > | > A no doubt elementary question, but .... > | > | > > | > | > using PHP and MySQL, I'm inserting a record into a table, with a > | > | > field, > | > | > order_number, being auto incremented ... something like: > | > | > > | > | > > | > | > $sql = "INSERT INTO orders set products_ordered='$products', > | > | > ordered_by='$username', company='$company', > | > address_1='$address_1', > | > | > address_2='$address_2', city='$city', > state='$state', zip='$zip', > | > | > attn='$attn', special_instructions='$special_instructions', > | > | > shipping_instructions='$shipping_instructions', > status='$status', > | > | > rush='$rush', date_ordered='$current_time' , > | > month_due='$month_due', > | > | > day_due='$day_due' > | > | > " ; > | > | > > | > | > $result = mysql_query($sql) or die("ERROR -- try again"); > | > | > > | > | > > | > | > > | > | > Having done so, how can I immediately determine the value of > | > | > order_number > | > | > for this entry, i.e. the auto-incremented value assigned by MySQL? > | > | > > | > | > Thanks in advance for the help. > | > | > > | > | > Kenn Murrah > | > | > > | > | > > | > | > > | > | > > | > | > -- > | > | > PHP Database Mailing List (http://www.php.net/) > | > | > To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net > | > | > For additional commands, e-mail: php-db-help@lists.php.net > | > | > To contact the list administrators, e-mail: > | > | > php-list-admin@lists.php.net > | > | > > | > | > > | > | > | > > | > > | > | -- > | PHP Database Mailing List (http://www.php.net/) > | To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net > | For additional commands, e-mail: php-db-help@lists.php.net > | To contact the list administrators, e-mail: php-list-admin@lists.php.net > | > | > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net > For additional commands, e-mail: php-db-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net > --

« previous php.db (#11451) next »