here's my code that is working perfectly
$Conn is the connection object
$sql = "INSERT INTO dp_survey_question (survey_id,question_type_id,question_text)
VALUES
(" . $s_id . "," . $qt_id . "," . $Conn->quote($q_text) . ")";
$result = $Conn->query($sql);
if (DB::isError($result)) {
die( $result->getMessage()."<br>".$sql );
}
$q_id = Mysql_Insert_ID($Conn->connection);
On Tue, 30 Oct 2001, Matthew Walker wrote:
> That won't work. The connection is being made through the PEAR DB class,
> so the standard PHP functions won't work. (And yes, I did just test it.)
>
> -----Original Message-----
> From: rc [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, October 30, 2001 1:58 PM
> To: Matthew Walker
> Cc: [EMAIL PROTECTED]
> Subject: Re: PHP/MySQL Problem
>
> Mysql_Insert_ID($dbhandle->connection);
>
> gets the last id of the last insert statement - if you do any db
> activity
> after the insert, this won't work.
>
> On Tue, 30 Oct 2001, Matthew Walker wrote:
>
> > Does anyone see anything wrong with the following code/query syntax?
> I'm
> > using the PEAR DB class for PHP. When this runs, it correctly inserts
> > the row to the table, but is failing to retrieve the last_insert_id().
> >
> > function StartOrder()
> > {
> > global $dbhandle;
> > global $OrderID;
> > global $CustomerID;
> >
> > if (!($OrderID)) {
> > $query = "INSERT INTO Orders (CustomerID) VALUES(";
> > if ($CustomerID) {
> > $query .= "\"" . $CustomerID . "\"";
> > } else {
> > $query .= "\"" . "\"";
> > }
> > $query .= ")";
> > $dbhandle->query("LOCK TABLES Orders WRITE");
> > $dbhandle->query($query);
> > $res = $dbhandle->query("select last_insert_id()");
> > $dbhandle->query("UNLOCK TABLES");
> > $result = $res->fetchRow();
> > return $OrderID = $result[0];
> > } else {
> > return $OrderID;
> > }
> > } // end func
> >
> > --
> > Matthew Walker
> > Ecommerce Project Manager
> > Mountain Top Herbs
> >
> >
> >
> > ---
> >
> >
> > --
> > Matthew Walker
> > Ecommerce Project Manager
> > Mountain Top Herbs
> >
> > ---
> > Outgoing mail is certified Virus Free.
> > Checked by AVG anti-virus system (http://www.grisoft.com).
> > Version: 6.0.286 / Virus Database: 152 - Release Date: 10/9/2001
> >
> >
> >
> > ---------------------------------------------------------------------
> > Before posting, please check:
> > http://www.mysql.com/manual.php (the manual)
> > http://lists.mysql.com/ (the list archive)
> >
> > To request this thread, e-mail <[EMAIL PROTECTED]>
> > To unsubscribe, e-mail
> <[EMAIL PROTECTED]>
> > Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
> >
>
> ---
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.286 / Virus Database: 152 - Release Date: 10/9/2001
>
>
---------------------------------------------------------------------
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)
To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php