Board index   FAQ   Search  
Register  Login
Board index php forum :: Database mySQL & php coding

Files not saving to directory correctly

Codes here !

Moderators: macek, egami, gesf

Files not saving to directory correctly

Postby smi4motion » Thu Jun 28, 2012 10:03 pm

Im new to PHP so please bare with me. Thanks

I created an edit form that will allow me to update the information as I need to. The problem Iam having is when the files moves the image to the directory, it does not save the filename+id. However, it does save the filename+id on the database. I need the image when saved to the directory "images" to include the ID# so it does not overwrite any files with the same file name. Please HELP.

<?php
/*
EDIT.PHP
Allows user to edit specific entry in database
*/

// creates the edit record form
// since this form is used multiple times in this file, I have made it a function that is easily reusable
function renderForm($id, $username, $datecreated, $reportcompletiondate, $reportstatus, $companyName, $contactFirst, $contactLast, $companyEmail, $lenderNotes, $primaryCustomer, $primaryPhone, $primaryWork, $primaryCell, $primaryAddress, $primaryCity, $primaryState, $primaryZip, $secondaryCustomer, $secondaryPhone, $secondaryWork, $secondaryCell, $secondaryAddress, $secondaryCity, $secondaryState, $secondaryZip, $primaryEmployerInformation, $primaryAdditionalContact, $primaryPropertyDescription, $firstVehicleType, $firstVehicleId, $firstVehicleColor, $firstVehicleLicense, $secondVehicleType, $secondVehicleid, $secondVehicleColor, $secondVehicleLicense, $firstAccountType, $firstBalanceDue, $firstMonthlyPayment, $firstDueDate, $firstAmountPaid, $firstAmountPastDue, $firstLastPayment, $firstDaysLate, $secondAccountType, $secondBalanceDue, $secondMonthlyPayment, $secondDueDate, $secondAmountPaid, $secondAmountPastDue, $secondLastPayment, $secondDaysLate, $thirdAccountType, $thirdBalanceDue, $thirdMonthlyPayment, $thirdDueDate, $thirdAmountPaid, $thirdAmountPastDue, $thirdLastPayment, $thirdDaysLate, $reportsummary, $reportphotos, $reportphotos2, $reportphotos3, $reportphotos4, $reportphotos5, $error)
{
?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Edit Record</title>
<style type="text/css">
body {
font-family: Arial, Helvetica, sans-serif;
font-size: 11px;
margin: 0px;
}
label {
font-family: Arial, Helvetica, sans-serif;
font-size: 8px;
}
h1 {
font-family: Arial, Helvetica, sans-serif;
font-size:20px;
font-weight:bold;
text-transform:uppercase;
}
h2 {
font-family: Arial, Helvetica, sans-serif;
font-size:14px;
font-weight:bold;
text-transform:uppercase;
}
</style>
</head>
<body>

<table width="100%" cellpadding="10" cellspacing="0" border="1" align="center">
<tr>
<td bgcolor="#cfcfaf">&nbsp;</td>

<td width="1000">

<table width="100%" cellpadding="5" cellspacing="0" border="0" align="center">
<tr>
<td bgcolor="#cfcfaf"><img src="http://www.streethawk-fcs.com/templates/everhest/images/logo.png" width="221" height="126" border="0"></td>
<td width="230" bgcolor="#cfcfaf" align="center"><h1>ADMIN UPDATE</h1></td>
</tr>
</table>

<?php
// if there are any errors, display them
if ($error != '')
{
echo '<div style="padding:4px; border:1px solid red; color:red;">'.$error.'</div>';
}
?>
<div align="right"><a href="user-logout.php">LOGOUT</a></div>
<p>&nbsp;</p>
<form action="" method="post" enctype="multipart/form-data">
<input type="hidden" name="id" value="<?php echo $id; ?>"/>

<div>
<table width="100%" cellpadding="5" cellspacing="0" border="0" align="center">
<tr>
<td bgcolor="#cfcfaf"><h2>Lender Information</h2></td>
</tr>
<tr>
<td> <table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td>&nbsp;</td>
<td align="right">Date Created (mm/dd/yyyy): <input name="datecreated" type="text" value="<?php echo $datecreated; ?>" size="30"/><br>
Completion Date (mm/dd/yyyy): <input name="reportcompletiondate" type="text" value="<?php echo $reportcompletiondate; ?>" size="30"/><br>
Status: <select name="reportstatus" id="reportstatus">
<option selected value="<?php echo $reportstatus; ?>"><?php echo $reportstatus; ?></option>
<option value="Open">Open</option>
<option value="In Process">In Process</option>
<option value="Completed">Completed</option>
</select>
</td>
</tr>
</table>
<br>

Company Name: <br>
<input name="companyName" type="text" value="<?php echo $companyName; ?>" size="50" />
<br>
<br>
<table cellpadding="3" cellspacing="0" border="0">
<tr>
<td>First Name:<br>
<input name="contactFirst" type="text" value="<?php echo $contactFirst; ?>" size="30" /></td>
<td>Last Name:<br>
<input name="contactLast" type="text" value="<?php echo $contactLast; ?>" size="30" /></td>
</tr>
</table>
<br>
Email:*<br>
<input name="companyEmail" type="text" value="<?php echo $companyEmail; ?>" size="50" />
<br/>
<br>
Notes:<br>
<!--<input type="text" name="lenderNotes" value="<?php echo $lenderNotes; ?>" /><br/>-->
<textarea name="lenderNotes" rows="5" cols="100" value="<?php echo $lenderNotes; ?>" /><?php echo $lenderNotes; ?></textarea> </td>
</tr>
<tr>
<td>&nbsp;</td>
</tr>
</table>
<table width="100%" cellpadding="5" cellspacing="0" border="0" align="center">
<tr>
<td bgcolor="#cfcfaf"><h2>Primary Customer Information</h2></td>
<td bgcolor="#cfcfaf"><h2>Secondary Customer Information</h2></td>
</tr>
<tr>
<td valign="top">
Customer Name:<br>
<input type="text" name="primaryCustomer" value="<?php echo $primaryCustomer; ?>" /><br/>
Home Phone (xxx-xxx-xxxx):<br>
<input type="text" name="primaryPhone" value="<?php echo $primaryPhone; ?>" /><br/>
Work Phone (xxx-xxx-xxxx):<br>
<input type="text" name="primaryWork" value="<?php echo $primaryWork; ?>" /><br/>
Cell Phone (xxx-xxx-xxxx):<br>
<input type="text" name="primaryCell" value="<?php echo $primaryCell; ?>" /><br/>
Address:<br>
<input type="text" name="primaryAddress" value="<?php echo $primaryAddress; ?>" /><br/>
City:<br>
<input type="text" name="primaryCity" value="<?php echo $primaryCity; ?>" /><br/>
State:<br>
<input type="text" name="primaryState" value="<?php echo $primaryState; ?>" /><br/>
Zip:<br>
<input type="text" name="primaryZip" value="<?php echo $primaryZip; ?>" /><br/> </td>
<td valign="top">
Customer Name:<br>
<input type="text" name="secondaryCustomer" value="<?php echo $secondaryCustomer; ?>" /><br/>
Home Phone (xxx-xxx-xxxx):<br>
<input type="text" name="secondaryPhone" value="<?php echo $secondaryPhone; ?>" /><br/>
Work Phone (xxx-xxx-xxxx):<br>
<input type="text" name="secondaryWork" value="<?php echo $secondaryWork; ?>" /><br/>
Cell Phone (xxx-xxx-xxxx):<br>
<input type="text" name="secondaryCell" value="<?php echo $secondaryCell; ?>" /><br/>
Address:<br>
<input type="text" name="secondaryAddress" value="<?php echo $secondaryAddress; ?>" /><br/>
City:<br>
<input type="text" name="secondaryCity" value="<?php echo $secondaryCity; ?>" /><br/>
State:<br>
<input type="text" name="secondaryState" value="<?php echo $secondaryState; ?>" /><br/>
Zip:<br>
<input type="text" name="secondaryZip" value="<?php echo $secondaryZip; ?>" /><br/>
</td>
<tr>
<td colspan="2" valign="top">
Employer Information:<br>
<textarea name="primaryEmployerInformation" cols="50" rows="5" value="<?php echo $primaryEmployerInformation; ?>" ><?php echo $primaryEmployerInformation; ?></textarea>
<br/>
Additional Contact:<br>
<input type="text" name="primaryAdditionalContact" value="<?php echo $primaryAdditionalContact; ?>" /><br/>
Property Description:<br>
<textarea name="primaryPropertyDescription" rows="5" cols="100" value="<?php echo $primaryPropertyDescription; ?>" /><?php echo $primaryPropertyDescription; ?></textarea>

</td>
</tr>
<tr>
<td colspan="2" valign="top">&nbsp;</td>
</tr>
</table>
<table width="100%" cellpadding="5" cellspacing="0" border="0" align="center">
<tr>
<td colspan="2" bgcolor="#cfcfaf"><h2>Vehicle Information</h2></td>
</tr>
<tr>
<td valign="top">
#1 Vehicle Type:<br>
<input type="text" name="firstVehicleType" value="<?php echo $firstVehicleType; ?>" /><br/>
Last Four ID:<br>
<input type="text" name="firstVehicleId" value="<?php echo $firstVehicleId; ?>" /><br/>
Vehicle Color:<br>
<input type="text" name="firstVehicleColor" value="<?php echo $firstVehicleColor; ?>" /><br/>
Vehicle License #:<br>
<input type="text" name="firstVehicleLicense" value="<?php echo $firstVehicleLicense; ?>" /> </td>
<td valign="top">
#2 Vehicle Type:<br>
<input type="text" name="secondVehicleType" value="<?php echo $secondVehicleType; ?>" /><br/>
Last Four ID:<br>
<input type="text" name="secondVehicleid" value="<?php echo $secondVehicleid; ?>" /><br/>
Vehicle Color:<br>
<input type="text" name="secondVehicleColor" value="<?php echo $secondVehicleColor; ?>" /><br/>
Vehicle License #:<br>
<input type="text" name="secondVehicleLicense" value="<?php echo $secondVehicleLicense; ?>" /> </td>
</tr>
<tr>
<td valign="top">&nbsp;</td>
<td valign="top">&nbsp;</td>
</tr>
</table>





<table width="100%" cellpadding="5" cellspacing="0" border="0" align="center">
<tr>
<td colspan="4" bgcolor="#cfcfaf"><h2>Financial Information</h2></td>
</tr>
<tr>
<td valign="top" width="25%">
Account Type:<br>
<select name="firstAccountType" id="firstAccountType">
<option selected value="<?php echo $firstAccountType; ?>"><?php echo $firstAccountType; ?></option>
<option value="Motor Vehicle">Motor Vehicle</option>
<option value="Deficiency Balance">Deficiency Balance</option>
<option value="Estate Account">Estate Account</option>
<option value="HELOC">HELOC</option>
<option value="Line of Credit">Line of Credit</option>
<option value="No Insurance">No Insurance</option>
<option value="Personal Loan">Personal Loan</option>
<option value="Mastercard">Mastercard</option>
<option value="Visa">Visa</option>
</select>
</td>
<td valign="top" width="25%">
Total Balance Due:<br>
<input type="text" name="firstBalanceDue" value="<?php echo $firstBalanceDue; ?>" /><br/>
Monthly Payment:<br>
<input type="text" name="firstMonthlyPayment" value="<?php echo $firstMonthlyPayment; ?>" /><br>
Payment Due Date (mm/dd/yyyy):<br>
<input type="text" name="firstDueDate" value="<?php echo $firstDueDate; ?>" />
</td>
<td valign="top" width="25%">
Amount Paid:<br>
<input type="text" name="firstAmountPaid" value="<?php echo $firstAmountPaid; ?>" /><br/>
Amount Past Due:<br>
<input type="text" name="firstAmountPastDue" value="<?php echo $firstAmountPastDue; ?>" />
</td>
<td valign="top" width="25%">
Date Last Payment (mm/dd/yyyy):<br>
<input type="text" name="firstLastPayment" value="<?php echo $firstLastPayment; ?>" /><br/>
Days Late:<br>
<select name="firstDaysLate" id="firstDaysLate">
<option selected value="<?php echo $firstDaysLate; ?>"><?php echo $firstDaysLate; ?></option>
<option value="1 - 30">1 - 30</option>
<option value="31 - 60">31 - 60</option>
<option value="61 - 90">61 - 90</option>
<option value="91 - 120">91 - 120</option>
<option value="121 - 150">121 - 150</option>
<option value="151 - 180">151 - 180</option>
<option value="181+">181+</option>
</select>
</td>
</tr>
</table>



<table width="100%" cellpadding="5" cellspacing="0" border="0" align="center">
<tr>
<td colspan="4"><hr></td>
</tr>
<tr>
<td valign="top" width="25%">
Account Type:<br>
<select name="secondAccountType" id="secondAccountType">
<option selected value="<?php echo $secondAccountType; ?>"><?php echo $secondAccountType; ?></option>
<option value="Motor Vehicle">Motor Vehicle</option>
<option value="Deficiency Balance">Deficiency Balance</option>
<option value="Estate Account">Estate Account</option>
<option value="HELOC">HELOC</option>
<option value="Line of Credit">Line of Credit</option>
<option value="No Insurance">No Insurance</option>
<option value="Personal Loan">Personal Loan</option>
<option value="Mastercard">Mastercard</option>
<option value="Visa">Visa</option>
</select>
</td>
<td valign="top" width="25%">
Total Balance Due:<br>
<input type="text" name="secondBalanceDue" value="<?php echo $secondBalanceDue; ?>" /><br/>
Monthly Payment:<br>
<input type="text" name="secondMonthlyPayment" value="<?php echo $secondMonthlyPayment; ?>" /><br/>
Payment Due Date (mm/dd/yyyy):<br>
<input type="text" name="secondDueDate" value="<?php echo $secondDueDate; ?>" /><br/></td>
<td valign="top" width="25%">
Amount Paid:<br>
<input type="text" name="secondAmountPaid" value="<?php echo $secondAmountPaid; ?>" /><br/>
Amount Past Due:<br>
<input type="text" name="secondAmountPastDue" value="<?php echo $secondAmountPastDue; ?>" /><br/> </td>
<td valign="top" width="25%">
Date Last Payment (mm/dd/yyyy):<br>
<input type="text" name="secondLastPayment" value="<?php echo $secondLastPayment; ?>" /><br/>
Days Late:<br>
<select name="secondDaysLate" id="secondDaysLate">
<option selected value="<?php echo $secondDaysLate; ?>"><?php echo $secondDaysLate; ?></option>
<option value="1 - 30">1 - 30</option>
<option value="31 - 60">31 - 60</option>
<option value="61 - 90">61 - 90</option>
<option value="91 - 120">91 - 120</option>
<option value="121 - 150">121 - 150</option>
<option value="151 - 180">151 - 180</option>
<option value="181+">181+</option>
</select> </td>
</tr>
</table>

<table width="100%" cellpadding="5" cellspacing="0" border="0" align="center">
<tr>
<td colspan="4"><hr></td>
</tr>
<tr>
<td valign="top" width="25%">
Account Type:<br>
<select name="thirdAccountType" id="thirdAccountType">
<option selected value="<?php echo $thirdAccountType; ?>"><?php echo $thirdAccountType; ?></option>
<option value="Motor Vehicle">Motor Vehicle</option>
<option value="Deficiency Balance">Deficiency Balance</option>
<option value="Estate Account">Estate Account</option>
<option value="HELOC">HELOC</option>
<option value="Line of Credit">Line of Credit</option>
<option value="No Insurance">No Insurance</option>
<option value="Personal Loan">Personal Loan</option>
<option value="Mastercard">Mastercard</option>
<option value="Visa">Visa</option>
</select>
</td>
<td valign="top" width="25%">
Total Balance Due:<br>
<input type="text" name="thirdBalanceDue" value="<?php echo $thirdBalanceDue; ?>" /><br/>
Monthly Payment:<br>
<input type="text" name="thirdMonthlyPayment" value="<?php echo $thirdMonthlyPayment; ?>" /><br/>
Payment Due Date (mm/dd/yyyy):<br>
<input type="text" name="thirdDueDate" value="<?php echo $thirdDueDate; ?>" /><br/>
</td>
<td valign="top" width="25%">
Amount Paid:<br>
<input type="text" name="thirdAmountPaid" value="<?php echo $thirdAmountPaid; ?>" /><br/>
Amount Past Due:<br>
<input type="text" name="thirdAmountPastDue" value="<?php echo $thirdAmountPastDue; ?>" /><br/>
</td>
<td valign="top" width="25%">
Date Last Payment (mm/dd/yyyy):<br>
<input type="text" name="thirdLastPayment" value="<?php echo $thirdLastPayment; ?>" /><br/>
Days Late:<br>
<select name="thirdDaysLate" id="thirdDaysLate" value="<?php echo $thirdLastPayment; ?>">
<option selected value="<?php echo $thirdLastPayment; ?>"><?php echo $thirdLastPayment; ?></option>
<option value="1 - 30">1 - 30</option>
<option value="31 - 60">31 - 60</option>
<option value="61 - 90">61 - 90</option>
<option value="91 - 120">91 - 120</option>
<option value="121 - 150">121 - 150</option>
<option value="151 - 180">151 - 180</option>
<option value="181+">181+</option>
</select>
</td>
</tr>
</table>

<p>&nbsp;</p>
<table width="100%" cellpadding="5" cellspacing="0" border="0" bgcolor="#fefecd">
<tr>
<td><hr></td>
</tr>
<tr>
<td> Report Summary<br>
<!--<input type="text" name="lenderNotes" value="<?php echo $reportsummary; ?>" /><br/>-->
<textarea name="reportsummary" rows="10" cols="100" value="<?php echo $reportsummary; ?>" /><?php echo $reportsummary; ?></textarea> <br>
<br>
Photos<br>
#1<input name="reportphotos" type="file" value="<?php echo $reportphotos; ?>" size="30"/><?php echo $reportphotos; ?><br>
#2<input name="reportphotos2" type="file" value="<?php echo $reportphotos2; ?>" size="30"/><?php echo $reportphotos2; ?><br>
#3<input name="reportphotos3" type="file" value="<?php echo $reportphotos3; ?>" size="30"/><?php echo $reportphotos3; ?><br>
#4<input name="reportphotos4" type="file" value="<?php echo $reportphotos4; ?>" size="30"/><?php echo $reportphotos4; ?><br>
#5<input name="reportphotos5" type="file" value="<?php echo $reportphotos5; ?>" size="30"/><?php echo $reportphotos5; ?><br>
<input type="hidden" name="id" value="<?php echo $id; ?>" />
</td>
</tr>
</table>




<div align="center"><input type="submit" name="submit" value="Update Report"></div>
</div>
</form>

</td>

<td bgcolor="#cfcfaf">&nbsp;</td>
</tr>
</table>

</body>
</html>
<?php
}

// connect to the database
include('connect-db.php');

// check if the form has been submitted. If it has, process the form and save it to the database
if (isset($_POST['submit']))
{
// confirm that the 'id' value is a valid integer before getting the form data
if (is_numeric($_POST['id']))
{
// get form data, making sure it is valid
$id = $_POST['id'];
$contactFirst = mysql_real_escape_string(htmlspecialchars($_POST['contactFirst']));
$contactLast = mysql_real_escape_string(htmlspecialchars($_POST['contactLast']));

// check that contactFirst/contactLast fields are both filled in
if ($contactFirst == '' || $contactLast == '')
{
// generate error message
$error = 'ERROR: Please fill in all required fields!';

//error, display form
renderForm($id, $contactFirst, $contactLast, $error);
}
else
{

//This is the directory where images will be saved
$target = "images/";
$target = $target . basename( $_FILES['reportphotos']['name']);
$target2 = "images/";
$target2 = $target2 . basename( $_FILES['reportphotos2']['name']);
$target3 = "images/";
$target3 = $target3 . basename( $_FILES['reportphotos3']['name']);
$target4 = "images/";
$target4 = $target4 . basename( $_FILES['reportphotos4']['name']);
$target5 = "images/";
$target5 = $target5 . basename( $_FILES['reportphotos5']['name']);


//This gets all the other information from the form
$pic=($_FILES['reportphotos']['name']);
$reportphotos=($id.$pic);
$pic2=($_FILES['reportphotos2']['name']);
$reportphotos2=($id.$pic2);
$pic3=($_FILES['reportphotos3']['name']);
$reportphotos3=($id.$pic3);
$pic4=($_FILES['reportphotos4']['name']);
$reportphotos4=($id.$pic4);
$pic5=($_FILES['reportphotos5']['name']);
$reportphotos5=($id.$pic5);
$id = $_POST['id'];

// save the data to the database
mysql_query("UPDATE clients SET datecreated='$datecreated', reportcompletiondate='$reportcompletiondate', reportstatus='$reportstatus', companyName='$companyName', contactFirst='$contactFirst', contactLast='$contactLast', companyEmail='$companyEmail', lenderNotes='$lenderNotes', primaryCustomer='$primaryCustomer', primaryPhone='$primaryPhone', primaryWork='$primaryWork', primaryCell='$primaryCell', primaryAddress='$primaryAddress', primaryCity ='primaryCity', primaryState='$primaryState', primaryZip='$primaryZip', secondaryCustomer='$secondaryCustomer', secondaryPhone='$secondaryPhone', secondaryWork='$secondaryWork', secondaryCell='$secondaryCell', secondaryAddress='$secondaryAddress', secondaryCity='$secondaryCity', secondaryState='$secondaryState', secondaryZip='$secondaryZip', primaryEmployerInformation='$primaryEmployerInformation', primaryAdditionalContact='$primaryAdditionalContact', primaryPropertyDescription='$primaryPropertyDescription', firstVehicleType='$firstVehicleType', firstVehicleId='$firstVehicleId', firstVehicleColor='$firstVehicleColor', firstVehicleLicense='$firstVehicleLicense', secondVehicleType='$secondVehicleType', secondVehicleid='$secondVehicleid', secondVehicleColor='$secondVehicleColor', secondVehicleLicense='$secondVehicleLicense', firstAccountType='$firstAccountType', firstBalanceDue='$firstBalanceDue', firstMonthlyPayment='$firstMonthlyPayment', firstDueDate='$firstDueDate', firstAmountPaid='$firstAmountPaid', firstAmountPastDue='$firstAmountPastDue', firstLastPayment='$firstLastPayment', firstDaysLate='$firstDaysLate', secondAccountType='$secondAccountType', secondBalanceDue='$secondBalanceDue', secondMonthlyPayment='$secondMonthlyPayment', secondDueDate='$secondDueDate', secondAmountPaid='$secondAmountPaid', secondAmountPastDue='$secondAmountPastDue', secondLastPayment='$secondLastPayment', secondDaysLate='$secondDaysLate', thirdAccountType='$thirdAccountType', thirdBalanceDue='$thirdBalanceDue', thirdMonthlyPayment='$thirdMonthlyPayment', thirdDueDate='$thirdDueDate', thirdAmountPaid='$thirdAmountPaid', thirdAmountPastDue='$thirdAmountPastDue', thirdLastPayment='$thirdLastPayment', thirdDaysLate='$thirdDaysLate', reportsummary='$reportsummary', reportphotos='$reportphotos', reportphotos2='$reportphotos2', reportphotos3='$reportphotos3', reportphotos4='$reportphotos4', reportphotos5='$reportphotos5' WHERE id='$id'")
or die(mysql_error());

//Writes the photo to the server
if(move_uploaded_file($_FILES['reportphotos']['tmp_name'], $target)) ;
if(move_uploaded_file($_FILES['reportphotos2']['tmp_name'], $target2)) ;
if(move_uploaded_file($_FILES['reportphotos3']['tmp_name'], $target3)) ;
if(move_uploaded_file($_FILES['reportphotos4']['tmp_name'], $target4)) ;
if(move_uploaded_file($_FILES['reportphotos5']['tmp_name'], $target5)) {

// once saved, redirect back to the view page
header("Location: adminview-paginated.php?page=1");
}
else {

//Gives and error if its not
echo "Sorry, there was a problem uploading your file.";
}

// once saved, redirect back to the view page
//header("Location: adminview-paginated.php?page=1");
}
}
else
{
// if the 'id' isn't valid, display an error
echo 'Error!';
}
}
else
// if the form hasn't been submitted, get the data from the db and display the form
{

// get the 'id' value from the URL (if it exists), making sure that it is valid (checing that it is numeric/larger than 0)
if (isset($_GET['id']) && is_numeric($_GET['id']) && $_GET['id'] > 0)
{
// query db
$id = $_GET['id'];
$result = mysql_query("SELECT * FROM clients WHERE id=$id")
or die(mysql_error());
$row = mysql_fetch_array($result);

// check that the 'id' matches up with a row in the databse
if($row)
{

// get data from db
$username=$row['username'];
$datecreated=$row['datecreated'];
$reportcompletiondate=$row['reportcompletiondate'];
$reportstatus=$row['reportstatus'];
$companyName = $row['companyName'];
$contactFirst = $row['contactFirst'];
$contactLast = $row['contactLast'];
$companyEmail = $row['companyEmail'];
$lenderNotes = $row['lenderNotes'];
$primaryCustomer = $row['primaryCustomer'];
$primaryPhone = $row['primaryPhone'];
$primaryWork = $row['primaryWork'];
$primaryCell = $row['primaryCell'];
$primaryAddress = $row['primaryAddress'];
$primaryCity = $row['primaryCity'];
$primaryState = $row['primaryState'];
$primaryZip = $row['primaryZip'];
$primaryEmployerInformation = $row['primaryEmployerInformation'];
$primaryAdditionalContact =$row['primaryAdditionalContact'];
$primaryPropertyDescription = $row['primaryPropertyDescription'];
$secondaryCustomer = $row['secondaryCustomer'];
$secondaryPhone = $row['secondaryPhone'];
$secondaryWork = $row['secondaryWork'];
$secondaryCell = $row['secondaryCell'];
$secondaryAddress = $row['secondaryAddress'];
$secondaryCity = $row['secondaryCity'];
$secondaryState = $row['secondaryState'];
$secondaryZip = $row['secondaryZip'];
$firstVehicleType = $row['firstVehicleType'];
$firstVehicleId = $row['firstVehicleId'];
$firstVehicleColor = $row['firstVehicleColor'];
$firstVehicleLicense = $row['firstVehicleLicense'];
$secondVehicleType = $row['secondVehicleType'];
$secondVehicleid = $row['secondVehicleid'];
$secondVehicleColor = $row['secondVehicleColor'];
$secondVehicleLicense = $row['secondVehicleLicense'];
$firstAccountType = $row['firstAccountType'];
$firstBalanceDue = $row['firstBalanceDue'];
$firstMonthlyPayment = $row['firstMonthlyPayment'];
$firstDueDate = $row['firstDueDate'];
$firstAmountPaid = $row['firstAmountPaid'];
$firstAmountPastDue = $row['firstAmountPastDue'];
$firstLastPayment = $row['firstLastPayment'];
$firstDaysLate = $row['firstDaysLate'];
$secondAccountType = $row['secondAccountType'];
$secondBalanceDue = $row['secondBalanceDue'];
$secondMonthlyPayment = $row['secondMonthlyPayment'];
$secondDueDate = $row['secondDueDate'];
$secondAmountPaid = $row['secondAmountPaid'];
$secondAmountPastDue = $row['secondAmountPastDue'];
$secondLastPayment = $row['secondLastPayment'];
$secondDaysLate = $row['secondDaysLate'];
$thirdAccountType = $row['thirdAccountType'];
$thirdBalanceDue = $row['thirdBalanceDue'];
$thirdMonthlyPayment = $row['thirdMonthlyPayment'];
$thirdDueDate =$row['thirdDueDate'];
$thirdAmountPaid = $row['thirdAmountPaid'];
$thirdAmountPastDue = $row['thirdAmountPastDue'];
$thirdLastPayment =$row['thirdLastPayment'];
$thirdDaysLate = $row['thirdDaysLate'];
$reportsummary = $row['reportsummary'];
$reportphotos = $row['reportphotos'];
$reportphotos2 = $row['reportphotos2'];
$reportphotos3 = $row['reportphotos3'];
$reportphotos4 = $row['reportphotos4'];
$reportphotos5 = $row['reportphotos5'];

// show form
renderForm($id, $username, $datecreated, $reportcompletiondate, $reportstatus, $companyName, $contactFirst, $contactLast, $companyEmail, $lenderNotes, $primaryCustomer, $primaryPhone, $primaryWork, $primaryCell, $primaryAddress, $primaryCity, $primaryState, $primaryZip, $secondaryCustomer, $secondaryPhone, $secondaryWork, $secondaryCell, $secondaryAddress, $secondaryCity, $secondaryState, $secondaryZip, $primaryEmployerInformation, $primaryAdditionalContact, $primaryPropertyDescription, $firstVehicleType, $firstVehicleId, $firstVehicleColor, $firstVehicleLicense, $secondVehicleType, $secondVehicleid, $secondVehicleColor, $secondVehicleLicense, $firstAccountType, $firstBalanceDue, $firstMonthlyPayment, $firstDueDate, $firstAmountPaid, $firstAmountPastDue, $firstLastPayment, $firstDaysLate, $secondAccountType, $secondBalanceDue, $secondMonthlyPayment, $secondDueDate, $secondAmountPaid, $secondAmountPastDue, $secondLastPayment, $secondDaysLate, $thirdAccountType, $thirdBalanceDue, $thirdMonthlyPayment, $thirdDueDate, $thirdAmountPaid, $thirdAmountPastDue, $thirdLastPayment, $thirdDaysLate, $reportsummary, $reportphotos, $reportphotos2, $reportphotos3, $reportphotos4, $reportphotos5, '');
}
else
// if no match, display result
{
echo "No results!";
}
}
else
// if the 'id' in the URL isn't valid, or if there is no 'id' value, display an error
{
echo 'Error!';
}
}
?>
smi4motion
New php-forum User
New php-forum User
 
Posts: 13
Joined: Mon Apr 02, 2012 7:39 am

Re: Files not saving to directory correctly

Postby smi4motion » Fri Jun 29, 2012 10:20 pm

Can anyone help me out with this?
smi4motion
New php-forum User
New php-forum User
 
Posts: 13
Joined: Mon Apr 02, 2012 7:39 am

Re: Files not saving to directory correctly

Postby johnj » Sun Jul 01, 2012 8:07 pm

Instead of using filename+id, use filename_id, (file under score id).

e.g.instead of having rightarrow+13.gif or rightarrow13.gif, try to have it as rightarrow_13.gif
johnj
php-forum Super User
php-forum Super User
 
Posts: 1805
Joined: Thu Mar 10, 2011 5:07 pm


Return to mySQL & php coding

Who is online

Users browsing this forum: Majestic-12 [Bot] and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.