Re: [PHP-DB] determining the value of an auto-incremented field (mysql)

2001-08-16 Thread Gremlins Mailing List

- Original Message -
From: Kenn Murrah [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Friday, August 17, 2001 1:17 AM
Subject: [PHP-DB] determining the value of an auto-incremented field (mysql)


[snip]

 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?

Use mysql_insert_id(), it returns the ID generated for an AUTO_INCREMENT
column by the previous INSERT query.


regards
--
Jason Wong
Gremlins Associates
www.gremlins.com.hk




-- 
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] determining the value of an auto-incremented field (mysql)

2001-08-16 Thread Brunner, Daniel

Say...


You can us it after you do your insert...then do something like.

echo (BYour 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 [EMAIL PROTECTED]
 To: 'Kenn Murrah' [EMAIL PROTECTED]
 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: [EMAIL PROTECTED]
 |  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: [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] determining the value of an auto-incremented field (mysql)

2001-08-16 Thread Kenn Murrah

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 again11 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 [EMAIL PROTECTED]
To: 'Kenn Murrah' [EMAIL PROTECTED]
Cc: PHP List (E-mail) [EMAIL PROTECTED]
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 (BYour 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 [EMAIL PROTECTED]
|  To: 'Kenn Murrah' [EMAIL PROTECTED]
|  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: [EMAIL PROTECTED]
|  |  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: [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]
|
|


-- 
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]