I've looked this over many times and can't see where I'm wrong. The code works fine except for the insert statement - it always displays the error "Did not add record. Try Again."
Can anyone else see my mistakes?
// ***************************************************************
// Do this if form is submitted...
// ***************************************************************
if ($HTTP_POST_VARS[submit]) { // Add the product
if (!$my_validator->validate_fields("name, manufacturer, categories, description")) {
echo $my_validator->error;
} else {
/*
$userfile - The temporary filename in which the uploaded file was stored on the server machine.
$userfile_name - The original name or path of the file on the sender's system.
$userfile_size - The size of the uploaded file in bytes.
$userfile_type - The mime type of the file if the browser provided this information. An example would be "image/gif".
*/
// ***************************************************************
// CONFIGURATIONS FOR IMAGE UPLOAD
// ***************************************************************
//main path of site on server, usually starts with www, public_html, or pages.
$dir="/www/izzymillerfurniture.com";
// DIRECTORY YOU WISH TO PUT THE FILES IN
$file_dir="$dir"."/"."images/inventory"; // DIRECTORY YOU WISH TO VIEW AND EDIT THE FILES IN
// DIRECTORY YOU WISH TO VIEW THE THUMBNAILS IN
$thumbs_dir="$dir"."/"."images/thumbs"; // DIRECTORY YOU WISH TO VIEW THE THUMBNAILS IN
//new_w = new width in pixels
//new_h = new height in pixels
$new_w=200;
$new_h=200;
// ***************************************************************
// DO NOT EDIT BELOW HERE
// ***************************************************************
$graphic="$file_dir"."/"."$userfile_name";
$graphics="$thumbs_dir"."/"."$userfile_name";
$f2 = "$userfile";
//if $userfile isn't empty, then copy new image to server and thumbnail it
if("$f2" != "none"){
stripslashes($userfile);
copy($userfile,$graphic);
//this creates a thumbnail and copies it to thumbnail directory
system("convert -quality 90 -sample '$new_wx$new_h' '$graphic' '$graphics'");
if (!is_uploaded_file ($userfile)){ //if not uploaded, spit back error
echo "<b>$userfile_name</b> couldn't be copied !!"; }
// check whether it has been uploaded
if (is_uploaded_file ($userfile)){ //if the image uploaded successfully, tell us that it was
echo "
<b>$userfile_name</b> copied succesfully !!"; }
} elseif ("$f2" == "none"){
stripslashes($userfile);
$userfile_name = "default.gif";
}
// ************************************************
// Add the products
// ************************************************
# Create the Query.
$sql = "INSERT INTO products(name, price, available, userfile, categories, manufacturer, description)
VALUES('$name', '$price', '$available', '$userfile_name', '$categories', '$manufacturer', '$description')";
//echo $sql;
//print(mysql_error());
# Make the Query
$ok = mysql_query ($sql);
if ( $ok ) { echo "<BR>Record added.<BR>"; }
else { echo " <font color=\"red\">\Did not add record. Try again.</font><br><br>";
add_products();
display_products();
die; }
}
}