Forum Moderators: coopster
Wonder if anyone can help.
I have a php page that has an option of either submitting user entered property details into a mySQL database or updating existing records.
Part of the submission is 5 images which are uploaded to a file on the server and the relevant path inserted into the DB.
This work fine for the insert but when I come to update a particular record the image path that is updated shows the original location of the image on my hard drive and so i get an image upload error and it doesnt show up on the web page.
The insert thats working is:
if ($_POST['add'] == "exec") {
if ($_POST['addproperty']!= "") {
include ("logoupload.php");
if ($_FILES['logo']['name'] == "") {
$logofile = ("");
}
elseif ($_FILES['logo']['name']!= "") {
$logofile = ("images/property/".urlencode($_FILES['logo']['name']));
}
$sql = ("INSERT INTO `exectv` (`uid`, `type`, `location`, `avail`, `whenAvail`, `district`, `city`, `postcode`, `country`, `ppm`, `beds`, `parking`, `garden`, `furniture`, `cntlen`, `description`, `logo`, `deposit`) VALUES ('', '$type', '$location', '$avdate', '$whenavailExec', '$district', '$city', '$postcode', '$country', '$ppm', '$beds', '$parking', '$garden', '$furniture', '$contract', '$description', '$logofile', '$deposit')");
$query_result = mysql_query($sql) or print $sql.":".mysql_error();
and the logoupload.php file is:
<?php
$uploaddirlogo = 'images/property/';
$uploadfilelogo = $uploaddirlogo . basename($_FILES['logo']['name']);
if (move_uploaded_file($_FILES['logo']['tmp_name'], $uploadfilelogo)) {
echo "Logo file is valid, and was successfully uploaded.<br />";
} else {
echo "Logo file upload failed, using default image...<br />";
}
?>
That all works ok but the problem stats when i try and modify a record and replace the image using the same logoupload.php file with the following code:
elseif ($_POST['modifyexec']!= "") {
if ($_POST['modify']!= "") {
include ("logoupload.php");
if ($_FILES['logo']['name'] == "") {
$logofile = ("");
}
elseif ($_FILES['logo']['name']!= "") {
$logofile = ("images/property/".urlencode($_FILES['logo']['name']));
}
$ins = ("UPDATE `executive` SET `type` = '$type', `location` = '$location', `avail` = '$avdate', `whenAvail` = '$whenavailExecUpdate', `district` = '$district', `city` = '$city', `postcode` = '$postcode', `country` = '$country', `ppm` = '$ppm', `beds` = '$beds', `parking` = '$parking', `garden` = '$garden', `furniture` = '$furniture', `cntlen` = '$contract', `description` = '$description', `logo` = '$logo', `deposit` = '$deposit' WHERE `uid` = '$modifyexec' LIMIT 1");
Does that make sense? Hope so.
Any help would really be appreciated.
Thanks