tags:

views:

66

answers:

2

I want to save the file path of a picture, AND the image name, in the same table, but separate fields of course. How can I execute it properly? I'm sure there is something significantly wrong in the code below, but I can't spot it. Thank you.

$sess_userid = mysql_real_escape_string($_SESSION['userid']);
$Image = mysql_real_escape_string($_FILES['file']['name']);
$PortraitPath = mysql_real_escape_string('profileportraits/' . $_FILES['file']['name']);

$query  = "UPDATE Members 
             SET PortraitPath = '$PortraitPath' 
           WHERE fldID='$sess_userid'";

$query2 = "UPDATE Members 
              SET Image = '$Image' 
            WHERE fldID='$sess_userid'";  

$result = mysql_query($query) or trigger_error(mysql_error().$query);
$result2 = mysql_query($query2) or trigger_error(mysql_error().$query2);
+2  A: 

Use a comma like this:

UPDATE Members 
   SET PortraitPath = '$PortraitPath', 
       Image = '$Image' 
 WHERE fldID = '$sess_userid'
Lobsterm
+7  A: 

You can update multiple fields in the same table at the same time.

 $query  = "UPDATE Members 
            SET PortraitPath = '$PortraitPath',
                Image = '$Image'
            WHERE fldID='$sess_userid'"; 


mysql_query($query) or trigger_error(mysql_error().$query);
Joey C.