updating image information on mysql using php form

Hi I am looking for some help with this, I like others are learning PHP, I have a form which updates an existing record on a mysql table and uploads the image file to the right directory,

This all works fine. However I can not work out what I need to do to update the image information on the database. I have got this far but just am not experienced enough at the moment to know where I am going wrong. Help is really appreciated as I am very keen to learn more about PHP. I was using the PHP from DW Server Behaviours to create the basic php and then adding in the PHP code for the image part.

[php]

<?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { if (PHP_VERSION < 6) { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; } $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? doubleval($theValue) : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; }} $editFormAction = $_SERVER['PHP_SELF']; if (isset($_SERVER['QUERY_STRING'])) { $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']); } if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form2")) { $updateSQL = sprintf("UPDATE exhib_stand SET exhib_name=%s, image_caption=%s, image_alt=%s WHERE exhib_ID=%s", GetSQLValueString($_POST['exhib_name'], "text"), GetSQLValueString($_POST['image_caption'], "text"), GetSQLValueString($_POST['image_alt'], "text"), GetSQLValueString($_POST['exhib_ID'], "int")); mysql_select_db($database_christmas, $christmas); $Result1 = mysql_query($updateSQL, $christmas) or die(mysql_error()); } $colname_exhibimages = "-1"; if (isset($_GET['exhib_ID'])) { $colname_exhibimages = $_GET['exhib_ID']; } mysql_select_db($database_christmas, $christmas); $query_exhibimages = sprintf("SELECT * FROM exhib_stand WHERE exhib_ID = %s", GetSQLValueString($colname_exhibimages, "int")); $exhibimages = mysql_query($query_exhibimages, $christmas) or die(mysql_error()); $row_exhibimages = mysql_fetch_assoc($exhibimages); $totalRows_exhibimages = mysql_num_rows($exhibimages); ?>

THIS IS THE CODE FOR THE IMAGE

<?php $uploadDir = 'uploads/'; if(isset($_POST['upload'])) { $fileName = $_FILES['userfile']['name']; $tmpName = $_FILES['userfile']['tmp_name']; $fileSize = $_FILES['userfile']['size']; $fileType = $_FILES['userfile']['type']; $filePath = $uploadDir . $fileName; $result = move_uploaded_file($tmpName, $filePath); if (!$result) { echo "Error uploading file"; exit; } if(!get_magic_quotes_gpc()) { $fileName = addslashes($fileName); $filePath = addslashes($filePath); } $query = "UPDATE exhib_stand SET image_name='$fileName', image_type='$fileType', image_size='$fileSize', image_path='$filePath' WHERE 'exhib_ID' =%s"; mysql_select_db($database_christmas); mysql_query($query) or die('Error, query failed : ' . mysql_error()); echo "
Files uploaded
"; } ?>[/b][/font][/size][/php]
Sponsor our Newsletter | Privacy Policy | Terms of Service