0

I am using the JQuery upload and crop plugin which can be found here:

http://www.webmotionuk.co.uk/jquery/image_upload_crop.php

The code works fine and as expected but the one change I wish to make is to insert the saved thumbnail name into a mysql table but for some reason I can't get this to work. It would be too much to post the full code so I will try and narrow it down:

updateavatar.php :

require("../db.php");

$avatar = mysql_real_escape_string($_POST['avatar']);
$email = mysql_real_escape_string($_POST['email']);

mysql_query("UPDATE admin SET avatar='".$avatar."' WHERE email='".$email."'");

Any help is greatly appreciated!

3
  • I had to do something similar, and the only way I could figure out how to debug it was to print to the error_log in the php file. If you do error_log($avatar. ' - ' .$email) does it print what you're expecting to see? Also, you're not passing in a connection string to mysql_query, so I'm assuming you already have a connection open. If not, you need it. If you do have a connection, does the mysql_query function return true or false? Commented Jul 7, 2011 at 20:37
  • thanks guys but the mysqlconnect in the db.php which is included. I added in the error_log but don't seem to get anything different. Also, the way it fails is simply not updating the appropriate row in the database. I don't see any errors at all to do with syntax etc. Commented Jul 7, 2011 at 20:54
  • whoops, my mistake, it appears that the error_log prints out admin which is the user I am signed in as so it appears the variable for the filename is wrong. From looking at the plug in code I was sure this was the right variable, hmmmmm Commented Jul 7, 2011 at 20:58

1 Answer 1

2

I received this message from WebMotionUk:

On version 1.2 of the script, on approximately line 246 (of the original file from the download) you should see this:

$cropped = resizeThumbnailImage($thumb_image_location, $large_image_location,$w,$h,$x1,$y1,$scale);
//Reload the page again to view the thumbnail

All you need to do is to add your database insert/update script directly below this line.

Therefore you should have the following:

$cropped = resizeThumbnailImage($thumb_image_location, $large_image_location,$w,$h,$x1,$y1,$scale);
mysql_query("UPDATE admin SET avatar='".$thumb_image_location."' WHERE    email='".$email."'"); 
//Reload the page again to view the thumbnail

Hope this helps anyone in the same situation.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.