Reputation: 24426
I'm trying to create a new row, in which the image name is the same as the recordID (plus '.png'). The recordID is an auto-incremented int.
This makes a new record:
mysql_query("INSERT INTO record (name,age) VALUES ('$name','$age'')");
..and this gets the recordID:
$newRecordID = mysql_insert_id();
but how do stick the recordID's value into a image_name column (plus '.png'), without having to search for it again?
Upvotes: 2
Views: 122
Reputation: 5609
You don't need to stick '.png' to your image at all, your logic implies that each record contains info about image with extension png. Why would you even need another column then to store the image name?
The second part is that you are using a reserved word for your column name. Keyword NAME
is reserved, you should always avoid it.
Upvotes: 2
Reputation: 1255
Maybe im missing somthing here but
mysql_query("INSERT INTO image (name,id) VALUES ("$newRecordID".'.png','$newRecordID')");
Upvotes: 0
Reputation: 78443
Best I'm aware MySQL offers no sequence manipulation functions. So you can't.
The best you can do is to wrap this in a stored procedure to avoid a round trip to the server.
Upvotes: 0