The id number won't go into the database???
Posted: Wed Jan 31, 2007 9:35 pm
The id number from the url is not added to the database. I know that the id number is in the url. It displays nothing when I echo the id which is strange. When I echo the id before the submit button code it displays. So the submit button is the problem. Can someone please have a look at my code below and tell me why this is happening? Thanks in advance.
Code: Select all
require "config.php";
// define variables
$findphoto = $_FILES['findphoto'];
$photo = mysql_real_escape_string($_POST['photo']);
$filename = mysql_real_escape_string($_POST['filename']);
//$id = $_GET['id']; // get the id number from the url
$arrErrors = array();
// on submit
if (isset($_POST['btnsubmit'])) {
if($_FILES['findphoto']['name'] == '') {
$arrErrors['findphoto'] = 'You did not select a photo to upload';
}
if ($photo == '') {
$arrErrors['photo'] = 'Please enter a photo name and file extension that you wish to upload for this clearing sale.';
}
if ($filename == '') {
$arrErrors['filename'] = 'Please enter a file name for the photo.';
}
if (count($arrErrors) == 0) {
$parent_id = $_GET['id'];
// insert the id into the table
$insert = "INSERT INTO `clearingsales_photos` (`parent_id`, `photos`, `filename`) VALUES ('$parent_id', '$photo', '$filename')";
if (mysql_query ($insert)) {
print "<strong>Photo and filename have been added to the database. Please don't forget to upload the files via ftp.</strong><br /><br />";
} else {
print "<p>Could not add the entry because: <b>" . mysql_error() . "</b>. The query was $insert.</p>";
}
} else {
// The error array had something in it. There was an error.
// Start adding error text to an error string.
$strError = '<div class="formerror"><p>Please check the following and try again:</p><ul>';
// Get each error and add it to the error string
// as a list item.
foreach ($arrErrors as $error) {
$strError .= "<li>$error</li>";
}
$strError .= '</ul></div>';
}
}