logo-dw

Go Back   Dreamweaver Club Forums > Hand Coders Forum > PHP
Register FAQ Members List Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Display Modes
Old 04-24-2012, 06:12 PM   #1
sydesign
 
Join Date: Jan 2011
Posts: 41
Default MySQL HELP... inserting images

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.
sydesign is offline   Reply With Quote
Old 04-25-2012, 02:04 AM   #2
edbr
edbr's Avatar
 
Join Date: Aug 2005
Location: Bali
Posts: 11,176
Default

you can store the information and insert a link to the path where the image is
__________________
If you're happy and you know it shake your meds!
different style links examples

Flight / Hotel search
Free script download
Bali Villas
edbr is offline   Reply With Quote
Old 04-25-2012, 04:44 AM   #3
sydesign
 
Join Date: Jan 2011
Posts: 41
Default

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).
sydesign is offline   Reply With Quote
Old 04-25-2012, 05:52 AM   #4
edbr
edbr's Avatar
 
Join Date: Aug 2005
Location: Bali
Posts: 11,176
Default

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
__________________
If you're happy and you know it shake your meds!
different style links examples

Flight / Hotel search
Free script download
Bali Villas
edbr is offline   Reply With Quote
Old 04-25-2012, 07:50 PM   #5
sydesign
 
Join Date: Jan 2011
Posts: 41
Default

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

PHP Code:
     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."
     } 
sydesign is offline   Reply With Quote
Old 04-26-2012, 02:31 AM   #6
edbr
edbr's Avatar
 
Join Date: Aug 2005
Location: Bali
Posts: 11,176
Default

comment out the update line and echo out $level and $size to see your values .
__________________
If you're happy and you know it shake your meds!
different style links examples

Flight / Hotel search
Free script download
Bali Villas
edbr is offline   Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 03:21 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Copyright 2006 DreamweaverClub.com