Hello everyone,
I'm having a problem uploading a image file to the server and adding the filename to my MySQL database. I do not get any error messages, but in the database field the file name and path gets inserted. Example C:\images\test.jpg and still no uploaded file. my code is below. thanks in advance.
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $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_insert"])) && ($POST["MM_insert"] == "form1")) {
$var = $FILES['propertyImg'] ['name'];
move_uploaded_file ($FILES['propertyImg'] ['tmp_name'],
"../propimages/{$_FILES['propertyImg'] ['name']}");
$insertSQL = sprintf("INSERT INTO offerings (pname, address, city, state, sqft, clearHeight, typeConstruction, additionalInfo, propertyImg, confientiality, memo, otherTitle1, otherFile1, otherTitle2, otherFile2, otherTitle3, otherFile3, otherTitle4, otherFile4, user, pass, displayOffering, buyer, seller, saleDate, mdesc, transSum, displayCaseStudy) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($POST['pName'], "text"),
GetSQLValueString($POST['address'], "text"),
GetSQLValueString($POST['city'], "text"),
GetSQLValueString($POST['state'], "text"),
GetSQLValueString($POST['sqft'], "text"),
GetSQLValueString($POST['clearHeight'], "text"),
GetSQLValueString($POST['typeConstruction'], "text"),
GetSQLValueString($POST['additionalInfo'], "text"),
GetSQLValueString($POST['propertyImg'], "text"),
GetSQLValueString($POST['confientiality'], "text"),
GetSQLValueString($POST['memo'], "text"),
GetSQLValueString($POST['otherTitle1'], "text"),
GetSQLValueString($POST['otherFile1'], "text"),
GetSQLValueString($POST['otherTitle2'], "text"),
GetSQLValueString($POST['otherFile2'], "text"),
GetSQLValueString($POST['otherTitle3'], "text"),
GetSQLValueString($POST['otherFile3'], "text"),
GetSQLValueString($POST['otherTitle4'], "text"),
GetSQLValueString($POST['otherFile4'], "text"),
GetSQLValueString($POST['user'], "text"),
GetSQLValueString($POST['pass'], "text"),
GetSQLValueString(isset($POST['displayOffering']) ? "true" : "", "defined","1","0"),
GetSQLValueString($POST['buyer'], "text"),
GetSQLValueString($POST['seller'], "text"),
GetSQLValueString($POST['saleDate'], "date"),
GetSQLValueString($POST['mdesc'], "text"),
GetSQLValueString($POST['transSum'], "text"),
GetSQLValueString(isset($POST['displayCaseStudy']) ? "true" : "", "defined","1","0"));
mysql_select_db($database_converse, $converse);
$Result1 = mysql_query($insertSQL, $converse) or die(mysql_error());
$insertGoTo = "offeringsStart.php";
if (isset($SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}