problem with query plz help

How to use phpmyadmin.... phpmyadmin related arguments. Even phpMyAdmin issues

Moderators: egami, macek, gesf

Post Reply
toweter
New php-forum User
New php-forum User
Posts: 26
Joined: Sat Aug 30, 2003 9:04 am

Fri Oct 24, 2003 1:24 pm

try it like that:
mysql_query("UPDATE table1 set item1='bar' WHERE id = ".LAST_INSERT_ID());

User avatar
swirlee
Moderator
Moderator
Posts: 2257
Joined: Sat Jul 05, 2003 1:18 pm
Location: A bunk in the back
Contact:

Fri Oct 24, 2003 1:42 pm

toweter wrote:try it like that:
mysql_query("UPDATE table1 set item1='bar' WHERE id = ".LAST_INSERT_ID());


Um, toweter.. LAST_INSERT_ID() is a MySQL function, not a PHP function, so it has to be part of the query. PHP will just throw a "undefined function" error.

Anyway, atroz, I'm guessing that the problem here is that, to quote the docs, "The last ID that was generated is maintained in the server on a per-connection basis." I'm guessing that between the time you create the record and when you try to UPDATE it, you've since created a new connection (e.g. you're running a different script or a different instance of the script).

You could just use MAX(id) instead, I suppose.
Image

Post Reply
  • Information
  • Who is online

    Users browsing this forum: No registered users and 1 guest