danarashad
Programmer
I am having some trouble, I am uploading an image. Then I do an insert into a DB, and do a select to grab the last insert. But for some reason I'll get an error. I don't get the error all of the time, but I do get it enough where its becoming a problem. I am using cflock, because I was told that would make sure that the insert happened before I do my select statement.
Here's the code I am using.
<cflock timeout="10">
<cfinsert tablename="gallery" datasource="table" formfields="name, position, image1">
<cfquery name="getNewID" datasource="table">
SELECT MAX(rec_id) as newID FROM gallery
</cfquery>
<cfquery name="getimage" datasource="table">
select image1 from gallery where rec_id=#getnewID.newID#
</cfquery>
</cflock>
<cfoutput>(#getimage.image1#)</cfoutput><br />
Here's the code I am using.
<cflock timeout="10">
<cfinsert tablename="gallery" datasource="table" formfields="name, position, image1">
<cfquery name="getNewID" datasource="table">
SELECT MAX(rec_id) as newID FROM gallery
</cfquery>
<cfquery name="getimage" datasource="table">
select image1 from gallery where rec_id=#getnewID.newID#
</cfquery>
</cflock>
<cfoutput>(#getimage.image1#)</cfoutput><br />