Addressed to: "Jacky@lilst" <[EMAIL PROTECTED]>
[EMAIL PROTECTED]
** Reply to note from "Jacky@lilst" <[EMAIL PROTECTED]> Fri, 19 Jan 2001
14:00:02 -0600
>
> Sorry, I think it should be like this:
>
> $queryInsert = "insert into user values ('firstname','lastname','email')";
> $resultinsert = mysql_query($queryInsert);
>
> $UserIdLatest = mysql_insert_id(userId);
>
>
> Is that correct?
Yes, that is the 'proper' way to find out the value of a auto_incremant
field. The SELECT MAX( userid ) method will work fine in testing, but
then you get to pull your hair out when it starts to fail under heavy
load.
You might have a bit of a problem with the values() clause of the
insert. That statement expects you to list all the entries in the
table, in the order they appear, unless you specify a list right after
the table name. I've given up on that syntax in favor of this one:
$QueryInsert = "INSERT INTO user SET " .
" firstname = '$FirstName', " .
" lastname = '$LastName', " .
" email = '$Email' );
It also works with update:
$QueryUpdate = "UPDATE user SET " .
" firstname = '$FirstName', " .
" lastname = '$LastName', " .
" email = '$Email' .
"WHERE userId = 1234 " );
I like the fact that you can list any fields in any order while leaving
out anything you want.
Rick Widmer
Internet Marketing Specialists
http://www.developersdesk.com
--
PHP General 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]