View Full Version : MySQL HELP... inserting images

04-24-2012, 05:12 PM
I have a task I'm trying to complete where my client wants to have users be able to upload pictures and then they will be displayed on a separate page but with the opportunity for a user to change info about the picture (i.e. a number associated with the picture). Trying to think through how to make it work. My original thought was that i could have the user upload the picture and it's info to e mysql database and then have it displayed on a page showing all the info associated with that image and i think i know how to change the info that way.

I have seen many people say inserting images into a database is a bad thing to do but what other option is there where i can store the image and all the info associated with it (i.e. date, time , location, title, username etc.)

i also can't seem to find a tutorial that will work for inserting an image in the database.

04-25-2012, 01:04 AM
you can store the information and insert a link to the path where the image is

04-25-2012, 03:44 AM
Thank you! I got that working now.

however, is there a way to have a member's "points" update with each picture uploaded.

what i mean is whenever someone uploads a picture (with a corresponding number) their point column in the database needs to update by that much (the corresponding number being added to the sum of their points column).

04-25-2012, 04:52 AM
off the hip i would suggest get the existing value
and end up with something like
$update_point= $row['points']+$newpoints:
then update the points field using $update_point

04-25-2012, 06:50 PM
Thank you so much it worked!

for some reason when i use this code it does add to the column however if the inputed amount is 9.5, when it adds to the column it rounds up to 10 i believe... is there was to have it added with the .5 other than making 9.5 round to 10

if(move_uploaded_file($_FILES['photo']['tmp_name'], $target))

include_once "../connect_to_mysql.php";

// Query member data from the database and ready it for display
$sql = mysql_query("SELECT * FROM members WHERE id='$userid'");
while($row = mysql_fetch_array($sql)){
$level = $row["level"];
//update level column
$userid = $_SESSION['id'];
$size = ereg_replace("[^.0-9]", "", $_POST['size']);
$update_point= $level+$size;
$sql = mysql_query("UPDATE members SET level='$update_point' WHERE id='$userid'");

//Tells you if its all ok
$successMsg = "<center><br />Thank you! The file \"" .$pic. "\" has been uploaded, and your information has been added to the directory!<br /><br /></center>";
else {

//Gives and error if its not
$errorMsg = "Sorry, there was a problem uploading your file.";

04-26-2012, 01:31 AM
comment out the update line and echo out $level and $size to see your values .