need help with upload image and getting image name to db



i'm using this upload code below.
i am a student working on an ecommerce project
i have an ecommerc website and an admin on the page that i have, i'm working on the admin part at the moment.
i want the admin to enter info into all of the fields that are provided such as the item name, item description, and item price, and item image.
here is the site that i'm working on for an example
i would like the name to be inserted into the datbase in order for the image to show up on the ecommerc website on the products pages here is my ecommerce site i have
can anyone help me out in getting the image name, which is being uploaded, to the database so that the image will show up on the products page of the ecommmerce website any help would be appreciated.
this is the code that i'm using for uploading the image and inserting the image into the database:

header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
<?php echo "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?".">"; ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<META HTTP-EQUIV='Pragma' CONTENT='no-cache' />
<META HTTP-EQUIV='Cache-Control' CONTENT='no-cache' />
<form action="<? $_SERVER['PHP_SELF']; ?>" method="post" ENCTYPE="multipart/form-data"> 
Choose a product category  <br>
<select name="txtCatID" id="select">
					<option value="0" SELECTED>0</option>
					<option value="1">1</option>
					<option value="2">2</option>
					<option value="3">3</option>
Choose product items to add to your product pages  <br>
   <input type="hidden" name="<?echo '$txtCatID';?>">
<select name="txtprodItems" id="select">
					<option value="Guitars" SELECTED>Guitars</option>
					<option value="Drums">Drums</option>
					<option value="Amps">Amps</option>
					<option value="Books">Books</option>
item name<br>
<input type="text" name="txtItemName"><br>
item description<br>
<input type="text" name="txtItemDesc"><br>
item price<br>
<input type="text" name="txtItemPrice"><br>
//START DB Stuff Here////////////////
	// specify the directory where the uploaded file should end up 
	$path = "/home/username/public_html/wootenmusic7/p_imgs/";
// specify the filetypes allowed 
$allowed = array('image/gif','image/pjpeg','image/jpeg','image/png'); 
// specify the max filesize in bytes 
$max_size = 200000; 
   if($_FILES['txtItemImage']['size'] < $max_size) 
     if(!file_exists($path . $_FILES['txtItemImage']['name'])) 
       $html_output = 'Upload sucessful!<br>'; 
       $html_output .= 'File Name: '.$_FILES['txtItemImage']['name'].'<br>'; 
       $html_output .= 'File Size: '.$_FILES['txtItemImage']['size'].' bytes<br>'; 
       $html_output .= 'File Type: '.$_FILES['txtItemImage']['type'].'<br>'; 
       $image = $_FILES['txtItemImage']['name'] ; 
       $html_output = 'Upload failed!<br>'; 
        //$html_output = 'The Directory "'.$path.'" must be writeable!<br>'; 
        $html_output = 'an unknown error ocurred.<br>';       
      $html_output = 'The file already exists<br>'; 
     $html_output = 'Wrong file type<br>'; 
    $html_output = 'The file is too big<br>'; 
  $html_output = '<form method="post" enctype="multipart/form-data" action="'.$_SERVER['PHP_SELF'].'">'; 
  $html_output .= '<input type="file" name="txtItemImage">'; 
  $html_output .= '<input type="submit" name="submit" value="upload"><input type="Reset" />'; 
  $html_output .= '</form>'; 
echo '<html><head><title>Uploader</title></head><body>'; 
echo $html_output; 
echo '</body></html>'; 
   $html_output = $_POST['submit'];
	// Get a connection to the database
	$cxn = @ConnectToDb($dbServer, $dbUser, $dbPass, $dbName);            
            $txtCatID = $_POST['txtCatID'];
            $txtprodItems = $_POST['txtprodItems'];
            $txtItemName = $_POST['txtItemName'];
            $txtItemDesc = $_POST['txtItemDesc'];
            $txtItemPrice = $_POST['txtItemPrice'];           
            $txtItemImage = $_FILES['txtItemImage']['name'];
echo "$theSQL";
$theSQL = "insert into items (prodItems, catid, itemName, itemDesc, itemPrice, ItemImage)";
$theSQL = $theSQL . " values ('$txtprodItems', '$txtCatID', '$txtItemName', '$txtItemDesc', '$txtItemPrice', '$txtItemImage')";
    $result = mysql_query($theSQL); 
	echo "$theSQL";
	echo "did not insert any image into database";
what you want is a very common requirement..,
please paste what error you receive..
the error that i'm getting is that when i'm uploading an image, the error comes back as 'upload failed'. it seems like the image is not being uploaded, but the image name seems to get to the database and the page that i'm displaying, displays the image name, but not the image. i would like the page to display the image when the image is being uploaded into a folder on my server. when the image is being uploaded, i would like the image name to get uploaded as well as the image name to get to the database so that the image will display.
Make sure u edited php.ini to allow you to upload files and set the correct directory to where it uploads :)
how would you edit php.ini? where would the file be located? would you edit that in the phpinfo.php page?
if so how would you edit that information?
sorry, i'm new to editing php.ini files, i haven't seen any ini files in my server. do i have to create an .ini file to chage the upload path?
please check the following in php.ini which could be in
/usr/local/lib/php.ini [try "locate php.ini"]
; File Uploads ;

; Whether to allow HTTP file uploads.
file_uploads = On

; Temporary directory for HTTP uploaded files (will use system default if not
; specified).
;upload_tmp_dir =

; Maximum allowed size for uploaded files.
upload_max_filesize = 20M

and uploading., you need write and execute permission for the user "nobody" that is Apache. make sure you have that for that directory
i have gave the write and execute permissions with 777, and i still get that error.
how do you find the php.ini file if i have a domain with a hosting company? i have searched through all of my files on my server and haven't found a php.ini file. do you know where it might be? i know you told me it'll be here /usr/local/lib/php.ini
but how do i find that through ftp?
or would i have to ask the hosting company im hosted with about the php ini file?
generally uploading is ON by default for hosting companies...

please put some echo statements in the IF ELSEIF ELSE blocks and try to find where the program is running....

post what error. you receive... !
i think the reason why its not uploading is because the upload_tmp_dir is not set. i think i have to set it in an .htaccess file since i can't get to a php.ini file on the hosting server that i'm using.
i think that i have to use something like this in the .htaccess file:
php_value upload_tmp_dir /home/username/public_html/folder11/images/

i still have to create the .htaccess file, once i do that, i'll see what kind of error the page gives me.
at the moment before doing that it just gives me an error of upload failed.