I am switching to PDO as per everyone's advice. The below script uploads the photo but nothing is added to the DB
<?php
///DEBUGGING
if (!empty($_POST)) {
print "<pre>This is your \$_POST array \n\n".print_r($_POST,true)."</pre>";
}
//This gets all the other information from the form
$Id = isset($_POST['Id']) ? $_POST['Id'] : 'NULL';
$Date = isset($_POST['Date']) ? $_POST['Date'] : '';
$Category = isset($_POST['Category']) ? $_POST['Category'] : '';
$Title = isset($_POST['Title']) ? $_POST['Title'] : '';
$Author = isset($_POST['Author']) ? $_POST['Author'] : '';
$Ctime = isset($_POST['Ctime']) ? $_POST['Ctime'] : '';
$Temp = isset($_POST['Temp']) ? $_POST['Temp'] : '';
$Prep = isset($_POST['Prep']) ? $_POST['Prep'] : '';
$Serves = isset($_POST['Serves']) ? $_POST['Serves'] : '';
$Details = isset($_POST['Details']) ? $_POST['Details'] : '';
$Ingredients = isset($_POST['Ingredients']) ? $_POST['Ingredients'] : '';
$Instructions = isset($_POST['Instructions']) ? $_POST['Instructions'] : '';
$Notes = isset($_POST['Notes']) ? $_POST['Notes'] : '';
$nutrition = isset($_POST['nutrition']) ? $_POST['nutrition'] : '';
$photo=($_FILES['photo']['name']);
$folder = $_POST['Category'];
// Connects to your Database
require('dbcadmin.php');
/////////////////////
//Writes the information to the database
$stmt = $conn->prepare("INSERT INTO recipes (Id, Date, Category, Title, Author, Ctime, Temp, Photo, Prep, Serves, Details, Ingredients, Instructions, Notes, nutrition) \n".
" VALUES (:Id, :Date, :Category, :Title, :Author, :Ctime, :Temp, :Photo, :Prep, :Serves, :Details, :Ingredients, :Instructions, :Notes, :nutrition) ");
$success=$stmt->execute(array(':Id'=>$Id, ':Date'=>$Date, ':Category'=>$Category, ':Title'=>$Title, ':Author'=>$Author, ':Ctime'=>$Ctime, ':Temp'=>$Temp, ':Photo'=>$Photo, ':Prep'=>$Prep, ':Serves'=>$Serves, ':Details'=>$Details, ':Ingredients'=>$Ingredients, ':Instructions'=>$Instructions, ':Notes'=>$Notes, ':nutrition'=>$nutrition));
/////////////////////
include('class.upload.php');
//Check that we have a file
// we instanciate the class for each element of $file
$handle = new Upload($_FILES['photo']);
// then we check if the file has been uploaded properly
// in its *temporary* location in the server (often, it is /tmp)
if ($handle->uploaded) {
$handle->auto_create_dir = false;
$handle->image_resize = true;
$handle->image_x = 400;
$handle->image_ratio_y = true;
// now, we start the upload 'process'. That is, to copy the uploaded file
// from its temporary location to the wanted location
// It could be something like $handle->Process('/home/www/my_uploads/');
$handle->process('/home/xxxxxxxxx/public_html/family/recipes/images/'.$folder);
// we check if everything went OK
if ($handle->processed) {
echo '<center><p>Image resized and uploaded to ' .$folder;
// everything was fine !
echo ' <a href="recipesview-pages.php">Go Back</a></p>';
} else {
// one error occured
echo '<p class="result">';
echo ' <b>File not uploaded to the wanted location</b><br />';
echo ' Error: ' . $handle->error . '';
echo '</p>';
}
} else {
// if we're here, the upload file failed for some reasons
// i.e. the server didn't receive the file
echo '<center><p class="result">';
echo ' <b>No file chosen for upload</b><br />';
echo ' ' . $handle->error . '';
echo '</p>';
}
?>
The values are all posting and the photo is uploaded but that's as far as it goes. Any assistance would be appreciated. Thanks!