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);
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);
Use a comma like this:
UPDATE Members
SET PortraitPath = '$PortraitPath',
Image = '$Image'
WHERE fldID = '$sess_userid'
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.