Re: [PHP-DB] getting ID

2001-08-20 Thread Ian Grant

mysql_insert_id([resource link_identifier]) returns the value of the
auto_increment field for the previous INSERT query. It will return 0 if
there is not an auto_increment field. If the link_identifier is not
specified, the last opened connection is used.

So, use $id = mysql_insert_id(); directly after your $result =
mysql_query($query); operation (where $query is an INSERT query) to pull the
id value you have just auto inserted back out.


Ian.

Manual page: http://www.php.net/manual/en/function.mysql-insert-id.php
Crosswalkcentral [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 I tried this and it gave me an error.

 Will this

 $id = mysql_insert_id();

 allow me to pull out the id?


 --
 Cross Walk Central
 www.crosswalkcentral.net
 Support Center
 Your Web Hosting Community!

 Cynic [EMAIL PROTECTED] wrote in message
 [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
  At 19:19 8/19/2001, CrossWalkCentral wrote the following:
  --
  I have a script where I submit user data to the database in my script I
 need
  to get the id  # how can I do this w/o creating a query that does the
  following considering that user could have 10 other entires.
 
  mysql_query(insert into ...);
  $id = mysql_insert_id();
 
 
  // Request info
  $result = mysql_query(
  SELECT * FROM supportsys WHERE email = $email);
  if (!$result) {
  echo(PError performing query:  .
  mysql_error() . /P);
  exit();
  }
  
  
  I basicly need to get the id$ of the record just entered
  --
  Cross Walk Central
  www.crosswalkcentral.net
  Support Center
  Your Web Hosting Community!
  
  
  
  
  --
  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]
  --end of quote--
 
 
  [EMAIL PROTECTED]
  -
  And the eyes of them both were opened and they saw that their files
  were world readable and writable, so they chmoded 600 their files.
  - Book of Installation chapt 3 sec 7
 





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

2001-08-20 Thread Walter, Marcel

Is there a similar function for a Sybase - Database ?

 -Original Message-
 From: Ian Grant [SMTP:[EMAIL PROTECTED]]
 Sent: Monday, August 20, 2001 12:20
 To:   [EMAIL PROTECTED]
 Subject:  Re: [PHP-DB] getting ID
 
 mysql_insert_id([resource link_identifier]) returns the value of the
 auto_increment field for the previous INSERT query. It will return 0 if
 there is not an auto_increment field. If the link_identifier is not
 specified, the last opened connection is used.
 
 So, use $id = mysql_insert_id(); directly after your $result =
 mysql_query($query); operation (where $query is an INSERT query) to pull
 the
 id value you have just auto inserted back out.
 
 
 Ian.
 
 Manual page: http://www.php.net/manual/en/function.mysql-insert-id.php
 Crosswalkcentral [EMAIL PROTECTED] wrote in message
 [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
  I tried this and it gave me an error.
 
  Will this
 
  $id = mysql_insert_id();
 
  allow me to pull out the id?
 
 
  --
  Cross Walk Central
  www.crosswalkcentral.net
  Support Center
  Your Web Hosting Community!
 
  Cynic [EMAIL PROTECTED] wrote in message
  [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
   At 19:19 8/19/2001, CrossWalkCentral wrote the following:
   --
   I have a script where I submit user data to the database in my script
 I
  need
   to get the id  # how can I do this w/o creating a query that does the
   following considering that user could have 10 other entires.
  
   mysql_query(insert into ...);
   $id = mysql_insert_id();
  
  
   // Request info
   $result = mysql_query(
   SELECT * FROM supportsys WHERE email = $email);
   if (!$result) {
   echo(PError performing query:  .
   mysql_error() . /P);
   exit();
   }
   
   
   I basicly need to get the id$ of the record just entered
   --
   Cross Walk Central
   www.crosswalkcentral.net
   Support Center
   Your Web Hosting Community!
   
   
   
   
   --
   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]
   --end of quote--
  
  
   [EMAIL PROTECTED]
   -
   And the eyes of them both were opened and they saw that their files
   were world readable and writable, so they chmoded 600 their files.
   - Book of Installation chapt 3 sec 7
  
 
 
 
 
 
 -- 
 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]


If you have received this e-mail in error or wish to read our e-mail disclaimer 
statement and monitoring policy, please refer to
http://www.drkw.com/disc/email/ or contact the sender.

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

2001-08-20 Thread tony . mccrory


With MSSQL I do:

$result=mssql_query(select @@IDENTITY as 'jobNumber');
$row=mssql_fetch_array($result);
$insertid=$row[jobNumber];

May be similar for sybase.. I understand they have similar origins..

Tony



   
 
Walter,   
 
Marcel   To: 'Ian Grant' 
[EMAIL PROTECTED], [EMAIL PROTECTED]  
Marcel.Waltercc:  
 
@drkw.comSubject: RE: [PHP-DB] getting ID 
 
   
 
08/20/2001 
 
11:22 AM   
 
   
 
   
 




Is there a similar function for a Sybase - Database ?

 -Original Message-
 From:   Ian Grant [SMTP:[EMAIL PROTECTED]]
 Sent:   Monday, August 20, 2001 12:20
 To: [EMAIL PROTECTED]
 Subject: Re: [PHP-DB] getting ID

 mysql_insert_id([resource link_identifier]) returns the value of the
 auto_increment field for the previous INSERT query. It will return 0 if
 there is not an auto_increment field. If the link_identifier is not
 specified, the last opened connection is used.

 So, use $id = mysql_insert_id(); directly after your $result =
 mysql_query($query); operation (where $query is an INSERT query) to pull
 the
 id value you have just auto inserted back out.


 Ian.

 Manual page: http://www.php.net/manual/en/function.mysql-insert-id.php
 Crosswalkcentral [EMAIL PROTECTED] wrote in message
 [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
  I tried this and it gave me an error.
 
  Will this
 
  $id = mysql_insert_id();
 
  allow me to pull out the id?
 
 
  --
  Cross Walk Central
  www.crosswalkcentral.net
  Support Center
  Your Web Hosting Community!
 
  Cynic [EMAIL PROTECTED] wrote in message
  [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
   At 19:19 8/19/2001, CrossWalkCentral wrote the following:
   --
   I have a script where I submit user data to the database in my
script
 I
  need
   to get the id  # how can I do this w/o creating a query that does
the
   following considering that user could have 10 other entires.
  
   mysql_query(insert into ...);
   $id = mysql_insert_id();
  
  
   // Request info
   $result = mysql_query(
   SELECT * FROM supportsys WHERE email = $email);
   if (!$result) {
   echo(PError performing query:  .
   mysql_error() . /P);
   exit();
   }
   
   
   I basicly need to get the id$ of the record just entered
   --
   Cross Walk Central
   www.crosswalkcentral.net
   Support Center
   Your Web Hosting Community!
   
   
   
   
   --
   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]
   --end of quote--
  
  
   [EMAIL PROTECTED]
   -
   And the eyes of them both were opened and they saw that their files
   were world readable and writable, so they chmoded 600 their files.
   - Book of Installation chapt 3 sec 7
  
 
 



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


If you have received this e-mail in error or wish to read our e-mail
disclaimer statement and monitoring policy, please refer to
http://www.drkw.com/disc/email/ or contact the sender.

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




IMPORTANT NOTICE  The information in this e-mail is confidential and should
only be read by those persons to whom it is addressed and is not intended
to be relied upon by any person without subsequent written confirmation of
its contents.  Furthermore, the content of this e-mail is the personal view
of the sender and does not represent the advice, views or opinion of our
company.  Accordingly, our company disclaim all responsibility and accept
no liability (including in negligence) for the consequences of any person
actin

RE: [PHP-DB] getting ID

2001-08-20 Thread Walter, Marcel

Yap ... this works quite fine with Sybase 

Thank you very much ...

 -Original Message-
 From: [EMAIL PROTECTED] [SMTP:[EMAIL PROTECTED]]
 Sent: Monday, August 20, 2001 12:27
 To:   Walter, Marcel
 Cc:   [EMAIL PROTECTED]
 Subject:  RE: [PHP-DB] getting ID
 
 
 With MSSQL I do:
 
 $result=mssql_query(select @@IDENTITY as 'jobNumber');
 $row=mssql_fetch_array($result);
 $insertid=$row[jobNumber];
 
 May be similar for sybase.. I understand they have similar origins..
 
 Tony
 
 
 
  
 
 Walter,
 
 Marcel   To: 'Ian Grant'
 [EMAIL PROTECTED], [EMAIL PROTECTED]  
 Marcel.Waltercc:
 
 @drkw.comSubject: RE: [PHP-DB]
 getting ID  
  
 
 08/20/2001
 
 11:22 AM
 
  
 
  
 
 
 
 
 
 Is there a similar function for a Sybase - Database ?
 
  -Original Message-
  From:   Ian Grant [SMTP:[EMAIL PROTECTED]]
  Sent:   Monday, August 20, 2001 12:20
  To: [EMAIL PROTECTED]
  Subject: Re: [PHP-DB] getting ID
 
  mysql_insert_id([resource link_identifier]) returns the value of the
  auto_increment field for the previous INSERT query. It will return 0 if
  there is not an auto_increment field. If the link_identifier is not
  specified, the last opened connection is used.
 
  So, use $id = mysql_insert_id(); directly after your $result =
  mysql_query($query); operation (where $query is an INSERT query) to pull
  the
  id value you have just auto inserted back out.
 
 
  Ian.
 
  Manual page: http://www.php.net/manual/en/function.mysql-insert-id.php
  Crosswalkcentral [EMAIL PROTECTED] wrote in message
  [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
   I tried this and it gave me an error.
  
   Will this
  
   $id = mysql_insert_id();
  
   allow me to pull out the id?
  
  
   --
   Cross Walk Central
   www.crosswalkcentral.net
   Support Center
   Your Web Hosting Community!
  
   Cynic [EMAIL PROTECTED] wrote in message
   [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
At 19:19 8/19/2001, CrossWalkCentral wrote the following:
--
I have a script where I submit user data to the database in my
 script
  I
   need
to get the id  # how can I do this w/o creating a query that does
 the
following considering that user could have 10 other entires.
   
mysql_query(insert into ...);
$id = mysql_insert_id();
   
   
// Request info
$result = mysql_query(
SELECT * FROM supportsys WHERE email = $email);
if (!$result) {
echo(PError performing query:  .
mysql_error() . /P);
exit();
}


I basicly need to get the id$ of the record just entered
--
Cross Walk Central
www.crosswalkcentral.net
Support Center
Your Web Hosting Community!




--
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]
--end of quote--
   
   
[EMAIL PROTECTED]
-
And the eyes of them both were opened and they saw that their files
were world readable and writable, so they chmoded 600 their files.
- Book of Installation chapt 3 sec 7
   
  
  
 
 
 
  --
  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]
 
 
 If you have received this e-mail in error or wish to read our e-mail
 disclaimer statement and monitoring policy, please refer to
 http://www.drkw.com/disc/email/ or contact the sender.
 
 --
 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]
 
 
 
 
 IMPORTANT NOTICE  The information in this e-mail is confidential and
 should
 only be read by those persons to whom it is addressed and is not intended
 to be relied upon by any person without subsequent written confirmation of
 its contents.  Furthermore, the content of this e-mail is the personal
 view
 of the sender and does not represent the advice, views or opinion of our
 company.  Accordingly, our company disclaim all responsibility and accept
 no liability (including in negligence) for the consequences of any person
 acting, or refraining from acting, on such information prior to the
 receipt
 by those persons of subsequent written confirmation.  In particular (but
 not by way of limitation) our company disclaims all responsibility and
 accepts no liability for any e-mails which are defamatory, offensive,
 racist or in any other way are in breach of any third party's ri

Re: [PHP-DB] getting ID

2001-08-20 Thread Ian Grant

Just a little addition...
I use this function to get the id value, given a field name, field data and
table name:

function getId($fname,$data,$tblName) {
GLOBAL $conn;
$query = SELECT id FROM $tblName WHERE $fname = '$data';
$result = mysql_query($query);
$row = mysql_fetch_row($result);
$id = $row[0];
return $id;
}

Ian.



Ian Grant [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 mysql_insert_id([resource link_identifier]) returns the value of the
 auto_increment field for the previous INSERT query. It will return 0 if
 there is not an auto_increment field. If the link_identifier is not
 specified, the last opened connection is used.

 So, use $id = mysql_insert_id(); directly after your $result =
 mysql_query($query); operation (where $query is an INSERT query) to pull
the
 id value you have just auto inserted back out.


 Ian.

 Manual page: http://www.php.net/manual/en/function.mysql-insert-id.php
 Crosswalkcentral [EMAIL PROTECTED] wrote in message
 [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
  I tried this and it gave me an error.
 
  Will this
 
  $id = mysql_insert_id();
 
  allow me to pull out the id?
 
 
  --
  Cross Walk Central
  www.crosswalkcentral.net
  Support Center
  Your Web Hosting Community!
 
  Cynic [EMAIL PROTECTED] wrote in message
  [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
   At 19:19 8/19/2001, CrossWalkCentral wrote the following:
   --
   I have a script where I submit user data to the database in my script
I
  need
   to get the id  # how can I do this w/o creating a query that does the
   following considering that user could have 10 other entires.
  
   mysql_query(insert into ...);
   $id = mysql_insert_id();
  
  
   // Request info
   $result = mysql_query(
   SELECT * FROM supportsys WHERE email = $email);
   if (!$result) {
   echo(PError performing query:  .
   mysql_error() . /P);
   exit();
   }
   
   
   I basicly need to get the id$ of the record just entered
   --
   Cross Walk Central
   www.crosswalkcentral.net
   Support Center
   Your Web Hosting Community!
   
   
   
   
   --
   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]
   --end of quote--
  
  
   [EMAIL PROTECTED]
   -
   And the eyes of them both were opened and they saw that their files
   were world readable and writable, so they chmoded 600 their files.
   - Book of Installation chapt 3 sec 7
  
 
 





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

2001-08-19 Thread Cynic

At 19:19 8/19/2001, CrossWalkCentral wrote the following:
-- 
I have a script where I submit user data to the database in my script I need
to get the id  # how can I do this w/o creating a query that does the
following considering that user could have 10 other entires.

mysql_query(insert into ...);
$id = mysql_insert_id();


// Request info
$result = mysql_query(
SELECT * FROM supportsys WHERE email = $email);
if (!$result) {
echo(PError performing query:  .
mysql_error() . /P);
exit();
}


I basicly need to get the id$ of the record just entered
--
Cross Walk Central
www.crosswalkcentral.net
Support Center
Your Web Hosting Community!




-- 
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]
--end of quote-- 


[EMAIL PROTECTED]
-
And the eyes of them both were opened and they saw that their files
were world readable and writable, so they chmoded 600 their files.
- Book of Installation chapt 3 sec 7 


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