Re: [PHP] mysql quickie..

2002-04-17 Thread Scott St. John

Kelly-

My way may not be perfect, but this is what I do.


$sql_temp = select last_insert_id() as mainid from transfers;
$sql_result_temp = mysql_query($sql_temp,$connection);
$row_temp = mysql_fetch_array($sql_result_temp);
$file_temp_id = $row_temp[mainid];


-Scott


On Wed, 17 Apr 2002, Kelly Meeks wrote:

 Hi folks,
 
 I need to get the next auto_increment value of a mysql table thru php.
 
 Looking at my mysql manual, it makes reference to a last_insert_id() function?
 
 How would I use this via php, or is there some other way to do it?
 
 Thanks
 
 Kelly
 
 

-- 



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] mysql quickie..

2002-04-17 Thread Robert Cummings

Kelly Meeks wrote:
 
 Hi folks,
 
 I need to get the next auto_increment value of a mysql table thru php.
 
 Looking at my mysql manual, it makes reference to a last_insert_id() function?
 
 How would I use this via php, or is there some other way to do it?

Quickly and hardly accurately... but good enough for useful purposes:

mysql_query( 'SELECT last_insert_id()' );
if( ($row = mysql_fetch_assoc()) )
{
$id = $row['last_insert_id()'];
}

Cheers,
Rob.
-- 
.-.
| Robert Cummings |
:-`.
| Webdeployer - Chief PHP and Java Programmer  |
:--:
| Mail  : mailto:[EMAIL PROTECTED] |
| Phone : (613) 731-4046 x.109 |
:--:
| Website : http://www.webmotion.com   |
| Fax : (613) 260-9545 |
`--'

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] mysql quickie..

2002-04-17 Thread Richard Emery

I've seen other responses to your request answer with some VERY UGLY methods
to get the last id.

Instead, use mysql_insert_id() which was created specifically for the info
you need.

- Original Message -
From: Kelly Meeks [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Wednesday, April 17, 2002 1:15 PM
Subject: [PHP] mysql quickie..


Hi folks,

I need to get the next auto_increment value of a mysql table thru php.

Looking at my mysql manual, it makes reference to a last_insert_id()
function?

How would I use this via php, or is there some other way to do it?

Thanks

Kelly

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] mysql quickie..

2002-04-17 Thread Robert Cummings

Richard Emery wrote:
 
 I've seen other responses to your request answer with some VERY UGLY methods
 to get the last id.

Hey my method wasn't ugly, perhaps not optimal, but definately not ugly!
So *ptht* ;)

 Instead, use mysql_insert_id() which was created specifically for the info
 you need.

Ummm yeah... I was gonna say that too, BUT FORGOT!

Cheers,
Rob.
-- 
.-.
| Robert Cummings |
:-`.
| Webdeployer - Chief PHP and Java Programmer  |
:--:
| Mail  : mailto:[EMAIL PROTECTED] |
| Phone : (613) 731-4046 x.109 |
:--:
| Website : http://www.webmotion.com   |
| Fax : (613) 260-9545 |
`--'

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] mysql quickie..

2002-04-17 Thread Richard Emery

- Original Message -
From: Robert Cummings [EMAIL PROTECTED]
To: Richard Emery [EMAIL PROTECTED]
Cc: Kelly Meeks [EMAIL PROTECTED]; [EMAIL PROTECTED]
Sent: Wednesday, April 17, 2002 1:49 PM
Subject: Re: [PHP] mysql quickie..


Richard Emery wrote:

 I've seen other responses to your request answer with some VERY UGLY
methods
 to get the last id.

 Hey my method wasn't ugly, perhaps not optimal, but definately not ugly!
 So *ptht* ;)

ROFL...


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php