Need help with code errors

The Code

[php]<?php

//This is the directory where images will be saved
$target = “images/”;
$target = $target . basename ($_FILES[‘photo’][‘did’]);

$did = $_POST[‘did’];
$name = $_POST[‘dname’];
$disc = $_POST[‘ddisc’];
$price = $_POST[‘dprice’];
$pic=($_FILES[‘photo’][‘did’]);

print_r($_POST);
session_start();
$con = mysql_connect("",“restoraunt”,“123456”);
if (!$con)
{
die('Could not connect: ’ . mysql_error());
}

mysql_select_db(“restoraunt”, $con);

//Writes the information to the database
mysql_query(“INSERT INTO menu VALUES (’$did’, ‘$name’, ‘$disc’, ‘$price’,‘a’,’$pic’)”) ;

/*************************/
//Writes the photo to the server
if(move_uploaded_file($_FILES[‘photo’][‘tmp_name’], $target))
{

//Tells you if its all ok
echo "The file “. basename( $_FILES[‘uploadedfile’][‘did’]). " has been uploaded, and your information has been added to the directory”;
}
else {

//Gives and error if its not
echo “Sorry, there was a problem uploading your file.”;
}
/**************************/

if (!mysql_query($sql,$con))
{
die('Error: ’ . mysql_error());
}
echo “1 record added”;

mysql_close($con);

?>[/php]
The Errors
Notice: Undefined index: photo in D:\WEB\Sites\Restoraunt\addDish.php on line 5

Notice: Undefined index: photo in D:\WEB\Sites\Restoraunt\addDish.php on line 17
Array ( [did] => 90 [dname] => uhh [ddisc] => jhjjhh [dprice] => 12 [dcateg] => Appetiser [photo] => Penguins.jpg [Add] => Add )
Notice: Undefined index: photo in D:\WEB\Sites\Restoraunt\addDish.php on line 40
Sorry, there was a problem uploading your file.
Notice: Undefined variable: sql in D:\WEB\Sites\Restoraunt\addDish.php on line 55
Error: Query was empty

hank you for the help

i guess, its the problem at html form end. coz, it is not finding $_FILES[‘photo’]. means, the name attribute of the might be something other than ‘photo’.

please check the name of the photo file upload control or post the html form code here so that i can verify.

Regards,

Sponsor our Newsletter | Privacy Policy | Terms of Service