I've got a simple sql query adding a brand new row to some database and want it to come back the a area to Javascript. The area does Auto_increment but stupildy I known as it 'itemId' so mysql_insert_id does not work and that i don't believe I've time for you to go and amend all of the php files which use 'itemId'

Here's my code whether it helps:

$addMainItem = "INSERT INTO newsItems (itemId, title, date, tags, location, latitude, longitude, visibleFrontpage, introText, fullDome, liveEvent, customServing, visitorAttraction, retail, digitalCinema, visiblePublic, thumbPath, links, smallDesc) VALUES ('','$title','$date','$tags','$loco','$lat','$long','$visiFront','$intro','$dome ','$live','$custom','$attrac','$retail','$cinema','$public','$thumbPath','$links','$smallDesc')";
$result = mysql_query($addMainItem) or die('error '.mysql_error());

if($result) echo (mysql_insert_id());

I have never heard that naming a column itemId breaking mysql_isert_id().

But you can easily choose the final placed record if auto_increment is working.

SELECT * FROM newsItems ORDER BY itemId DESC LIMIT 1

Place the the choose statement right into a transaction using the place statement if you are using innoDB and you are concerned about a race condition.

mysql_query("SELECT LAST_INSERT_ID()");

Is not it what exactly are you searching for?