problem with query plz help

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

Moderators: macek, egami, gesf

atroz
New php-forum User
New php-forum User
Posts: 3
Joined: Fri Oct 24, 2003 12:12 pm

problem with query plz help

Postby atroz » Fri Oct 24, 2003 12:25 pm

hi all
anyone know how can i update the last row in the table i try with LAST_INSERT_ID but dont work to me.
i try something like this

UPDATE table1 set item1='bar' WHERE id = LAST_INSERT_ID()

THX a lot

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

Postby toweter » 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: 2272
Joined: Sat Jul 05, 2003 1:18 pm
Location: A bunk in the back
Contact:

Postby swirlee » 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.


Return to “phpMyAdmin”

Who is online

Users browsing this forum: No registered users and 0 guests