cseasy
08-30-2005, 11:05 PM
Guys,
I am doing an insert, for which I want to get the auto-increment value back as a recordet in the same connection, I have the following:
$query = "";
$query = $query . "INSERT INTO ";
$query = $query . " myTable ";
$query = $query . " (name,summary) VALUES ";
$query = $query . " ('" . urlencode($_POST["frmName"]) . "','" . urlencode($_POST["frmSummary"]) . )";
//echo "Query: " . $query;
$result = mysql_query($query) or die('Query failed: ' . mysql_error());
I want to add to the query:
$query = $query . "SELECT DISTINCT @@Identity AS 'newId' FROM myTable";
When trying a semicolan seperator, I get an error (this is also true in my query analyser - it doesn't work there either.) Is this even possible, and if so, what am I doing wrong?
(The queries each by themselves do work by the way.)
Thanks,
C.
I am doing an insert, for which I want to get the auto-increment value back as a recordet in the same connection, I have the following:
$query = "";
$query = $query . "INSERT INTO ";
$query = $query . " myTable ";
$query = $query . " (name,summary) VALUES ";
$query = $query . " ('" . urlencode($_POST["frmName"]) . "','" . urlencode($_POST["frmSummary"]) . )";
//echo "Query: " . $query;
$result = mysql_query($query) or die('Query failed: ' . mysql_error());
I want to add to the query:
$query = $query . "SELECT DISTINCT @@Identity AS 'newId' FROM myTable";
When trying a semicolan seperator, I get an error (this is also true in my query analyser - it doesn't work there either.) Is this even possible, and if so, what am I doing wrong?
(The queries each by themselves do work by the way.)
Thanks,
C.