Hi sorry to be a pain but that didnt work, i thought it might be something else in the code but i cant find anything wrong with but i am a total novice here is the full page code,
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Jetstore | Adminstration</title>
</head>
<body>
<?php
// This page allows the administrator to add a product.
require_once ('include/mysql_connect.php'); // Connect to the database.
if (isset($_POST['submitted'])) { // Check if the form has been submitted.
// Validate the product_name, image, category (existing or first_name, last_name, middle_name), size, price, and description.
// Check for a print name.
if (!empty($_POST['product_name'])) {
$pn = escape_data($_POST['product_name']);
} else {
$pn = FALSE;
echo '<p><font color="red">Please enter the product\'s name!</font></p>';
}
// Check for an image.
if (is_uploaded_file ($_FILES['image']['tmp_name'])) {
if (move_uploaded_file($_FILES['image']['tmp_name'], "uploads/{$_FILES['image']['name']}")) { // Move the file over.
echo '<p>The file has been uploaded!</p>';
} else { // Couldn't move the file over.
echo '<p><font color="red">The file could not be moved.</font></p>';
$i = FALSE;
}
$i = $_FILES['image']['name'];
} else {
$i = FALSE;
}
// Check for a price.
if (is_numeric($_POST['price'])) {
$p = (float) $_POST['price'];
} else {
$p = FALSE;
echo '<p><font color="red">Please enter the product\'s price!</font></p>';
}
// Check for a description
if (!empty($_POST['description'])) {
$d = escape_data($_POST['description']);
} else {
$d = '<i>No description available.</i>';
}
// Validate the artist.
if ($_POST['category'] == 'new') {
// If it's a new category, add the category to the database.
$query = 'INSERT INTO category (category_name, category_desc) VALUES (';
if (!empty($_POST['category_name'])) {
$query .= "'" . escape_data($_POST['category_name']) . "', ";
} else {
$query .= 'NULL, ';
}
//maybe a } is need
// Check for a last_name.
if (!empty($_POST['category_desc'])) {
$query .= "'" . escape_data($_POST['category_desc']) . "')";
// Improved MySQL Version:
$result = mysql_query($query,$dbc);
$a = mysql_insert_id($dbc);
//$result = mysql_query ($query); // Run the query.
//$a = mysql_insert_id(); // Get the category ID.
} else { // No website value.
$a = FALSE;
echo '<p><font color="red">Please enter the category\'s website!</font></p>';
}
} elseif ( ($_POST['category'] == 'existing') && ($_POST['existing'] > 0)) { // Existing category.
$a = (int) $_POST['existing'];
} else { // No artist selected.
$a = FALSE;
echo '<p><font color="red">Please enter or select the products\'s category!</font></p>';
}
if ($pn && $p && $a && $i) { // If everything's OK.
// Add the print to the database.
$query = "INSERT INTO product (product_name, category_id, price, product_desc, image_name) VALUES ('$pn', '$a', $p,'$d', '$i')";
if ($result = mysql_query ($query)) { // Worked.
echo '<p>The product has been added.</p>';
} else { // If the query did not run OK.
echo '<p><font color="red">Your submission could not be processed due to a system error.</font></p>';
}
} else { // Failed a test.
echo '<p><font color="red">Please click "back" and try again.</font></p>';
}
} else { // Display the form.
?>
<form enctype="multipart/form-data" action="admin.php" method="post">
<input type="hidden" name="MAX_FILE_SIZE" value="524288">
<fieldset><legend>Fill out the form to add a print to the catalog:</legend>
<p><b>Product Name:</b>
<input type="text" name="product_name" size="30" maxlength="60" /></p>
<p><b>Image:</b> <input type="file" name="image" /> <small>The file name should not include spaces or other invalid characters and should have a file extension.</small></p>
<p><b>Category:</b>
<p><input type="radio" name="category" value="existing" /> Existing =>
<select name= "existing"> <option><--Please Select A Category--></option>
<?php // Retrieve all the categories and add to the pull-down menu.
$query = "SELECT category_id, category_name FROM category ORDER BY category_name ASC";
$result = mysqli_query ($dbc, $query);
while ($row = mysqli_fetch_array ($result)) {
echo "<option value=\"{$row[category_name]}\">{$row[category_name]}</option>\n";
}
mysqli_close($dbc); // Close the database connection.
?>
<p>
<input type="radio" name="category" value="new" /> New =>
Category Name: <input type="text" name="category_name" size="25"/>
<br /><br />
Category Description:<textarea name="category_desc" cols="40" rows="5"></textarea></p>
<p>Price: <input type="text" name="price" size="10" maxlength="10" />
<small>Do not include the currency sign or commas.</small></p>
<p>Product Description:<textarea name="description" cols="40" rows="5"></textarea></p
</fieldset>
<div align="center"><input type="submit" name="submit" value="Submit" /></div>
<input type="hidden" name="submitted" value="TRUE" />
</form>
<?php
} // End of main conditional.
?>
</body>
</html>