close ad
Install the LAtest Updates to Work with CC 2017 and CC 2018
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

found issue with thumbnail entry into DB

Thread began 1/12/2010 4:57 pm by deafboyz_audio386924 | Last modified 1/20/2010 2:41 pm by Jimmy Wu | 1073 views | 7 replies |

deafboyz_audio386924

found issue with thumbnail entry into DB

i have an upload form that upon successful thumbnail creation, adds the filename into an array.... An array is also made of filenames for the fullsize as well

The fullsize filenames are insertind into the DB and then i have a loop set up that does this:

//loop through thumbs array 	 	 
foreach ($uploaded_thumbs_array as $item2){
//split t_filename.extension into ".extension" and "t_filename" and "filename"
$item2_chop_block = explode(".",$item2);
$item2_ext = ".$item2_chop_block[1]";
$item2_filename = "$item2_chop_block[0]";
$item2_t_stripped = str_replace('t_','',$item2_filename);
//insert SQL
$query2 = "UPDATE pics SET thumb_filename = '$item2_filename', thumb_filename_ext = '$item2_ext' WHERE pic_filename = '$item2_t_stripped'";
mysql_select_db($database_db294582132, $db294582132);
mysql_query($query2, $db294582132) or die(mysql_error());
}



What this loop does is that it takes the t_filename(how my settings are set to name thumbs) and breaks off the 't_'

Then it finds the row with that filename and updates it with the name of the thumb.

I was testing all day and using the same 2 files over and over(my settings are set to rename with an incrementing number)

so eventually i got to IMGblah_59... and the thumb filenames were no longer inserted into the DB.....

So i went to my remote server and deleted all the duplicate images.

Retried the upload and the thumbnail insert now works. It wasn't working b/c the incrementing filenames had got too high and it was trippin out for some reason....

The thumb was still saved on the server and named correctly but the name was not inserted into the DB...

any ideas why?

Sign in to reply to this post

Jimmy Wu

Are the fullsize file names being inserted into the database even when it gets to that high of a number?

One thing you can do is to have 2 different directories for the regular size and thumbnails and then name them the same way. This way you won't have to go and remove the t_ from the thumbnail name.

Was it anything over 59 that wasn't working correctly? Could you try copying the images back into that directory and try uploading the image again to see if that was the actual cause?

Sign in to reply to this post

deafboyz_audio386924

Yes, fullsize names are still inserted into DB at that high of a number

I currently have 2 different directories for the thumbs and fullsize.... but the filenames are stored in the same row in the DB.

The caption, etc are the same for both so i put them in the same row...

I was taking the 't_' off of the thumb name so that it becomes the fullsize name..

Then i would use that name to update the correct row where the fullsize version of that pic was... make sense?

I have tested it lots of times and on a group of 5 uploads, none of the high numbers were working.... deleted them from the server and then it worked.... that was the only thing that was changed.

since then I have noticed that it occasionally skips the thumbnail entry to DB on lower numbers as well... it skipped it on one that was supposed to be t_dock_2

not sure why it does it randomly... code is supposed to be consistent, especially when you havent changed it at all.... ever heard of this?

Sign in to reply to this post

Jimmy Wu

This would most likely be because the update occurs before the row gets inserted into the database, so the row is not found and the update cannot be made. The insert may take longer when there are higher names due to having more items in the database already, so that would explain the error occurring more on higher numbers.

What you can do is to just insert the thumbnail and the regular image name at the same time, which would eliminate the need to insert and then update. Is there a reason you can't do the insert all at the same time?

Sign in to reply to this post

deafboyz_audio386924

Originally Said By: Jimmy Wu
  Is there a reason you can't do the insert all at the same time?  



That would be a possibility but i might need some help on the logic to do that. Right now I have 2 arrays made of the thumbs and fullsize. I need to count the number of thumbs so thats why i have 2.

Not sure how i could loop through 2 different arrays and take one item from each array and insert into the same row....

is this possible? if not I have some other ideas i might run past ya.

Sign in to reply to this post

Jimmy Wu

Yes, you can loop through 2 arrays at the same time and insert both values into the database at the same time.

Are you inserting the values into the database using DataAssist?

Sign in to reply to this post

deafboyz_audio386924

no i am not, im kickin it old school....
maybe later i might, maybe for use with e cart... i dont know

but i wont have it for this right now so...
Would there ever be a case where the 2 filenames didnt get inserted into the same row b/c one was lagging?... like is happening with the thumb name now.

How would you look through 2 arrays at the same time and insert into the same row?

Sign in to reply to this post

Jimmy Wu

While looping, you just step through both arrays and then in the insert, you would insert both the values.

There wouldn't be any issue, since it is one insert statement that is inserting all the information, so the values will be inserted simultaneously. The reason you were having the issue is that it was 2 different statements to first insert and then update the row.

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...