close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

ItemID out of Sync

Thread begun 9/25/2011 8:46 am by doug.lemesurier305760 | Last modified 9/26/2011 8:05 am by doug.lemesurier305760 | 2398 views | 3 replies |

doug.lemesurier305760

ItemID out of Sync

Hi,

I am using DA and UE to insert a record into a MySQL DB.

I am using UE to upload an image with the insert form.

The image uploads and the DB updates fine.

My problem is... I am using the ItemID to rename the uploaded image. (WADA_Insert_items).

This is not working as I would expect.
1) If I launch a new browser session and preform an insert, I get a file name of '.jpg'
2) On a secondary attempt, in the same session, I get a file name of (e.x. '99.jpg'). This is exactly one count of the actual ItemID of 100.

How can I correct this so that it work for the start of a new session and names the files accordingly.

The following is a SQL and session DUMP from the Detal page following an insert.

SQL: SELECT VisitorID, VisitorGroupID, CompanyID, ItemID, ItemCatID, ItemName, ItemShortDesc, ItemLongDesc, helixNumber, CustomerPartNumber, PONumber, OrderQTY, QTYProduced, release1, QTYOnHand FROM items WHERE ItemID = -1 OR ( -1= -1 AND ItemID= 100)

array(17) {
["WAENCRYPTEDRETURNUSED"]=>
bool(false)
["WAENCRYPTEDRETURNSUCCESS"]=>
bool(false)
["SecurityAssist_VisitorID"]=>
string(1) "1"
["VisitorGroupID"]=>
string(1) "3"
["VisitorEmail"]=>
string(28) "support@heliximpressions.com"
["VisitorBillName"]=>
string(22) "Helix Impressions Inc."
["VisitorID"]=>
string(1) "1"
["userID"]=>
string(5) "helix"
["UserName"]=>
string(5) "helix"
["CompanyID"]=>
string(1) "1"
["CompanyName"]=>
string(22) "Helix Impressions Inc."
["GroupName"]=>
string(20) "Helix Administrators"
["showContent"]=>
int(1)
["editContent"]=>
int(1)
["WADA_OrderClause_index"]=>
string(0) ""
["Insert_ImageName"]=>
string(12) "99_thumb.jpg"
["WADA_Insert_items"]=>
int(100)
}

Sign in to reply to this post

doug.lemesurier305760

ItemID out of Sync - solved?

I think I figured this one out.

The ItemID's were out of sync because there is no way - that I can find - to get the next MySQL, auto-increment id without inserting a record first. So I was unable to generate the proper file name to be inserted into the record before the actual record insert.

The solution was kind of simple. In a nut shell I...
1. saved my update.php as insert.php
2. modified new insert.php to execute a INSERT query, before page load, to create a blank row. (I just gave one of the numeric fields a zero value)
3. grabbed the 'mysql_insert_id();' value and used it to generate an UPDATE query.

Granted, it's not perfect. If the user changes their mind after loading the insert.php, it will leave a blank record behind. I've got to figure that one out.

If anyone has a better way or any suggestions, please let me know.

Cheers
Doug

Sign in to reply to this post

Jason ByrnesWebAssist

using the database ID as the file name is not going to be very practical.

to upload an image, and store it's in a database, the order of operations is:
File Upload
Database Insert.

The ID of the inserted record cannot be known until the record has been inserted.

because the upload happens before the insert, using the ID is not going to work very well.

Sign in to reply to this post

doug.lemesurier305760

Thanks Jason,

The method of turning the INSERT into an UPDATE seems to achieve my goal.

The blank insert generates the ID and I can use that value to perform an UPDATE that can now use that ID for an Image File name.

The reason I am stuck with using the record ID is: the form has very few data constraints, so there are no other usable vales at the form level. Also, the native naming convention of my client's files could be very long and contain spaces and other nasty things.

So, the record ID seemed to me to be the only reliable choice.

If I can't figure out an intelligent solution to the abandoned records issue, that I may have to just use the native file name and standard insert.

Cheers
Doug

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...