Jump to content

[SOLVED] Undefined index:


sandbudd

Recommended Posts

why am I getting these errors please?

 

Notice: Undefined variable: upload_feedback in /home/anodizi/public_html/image/upload2.php on line 48

 

Notice: Undefined variable: upload_feedback in /home/anodizi/public_html/image/upload2.php on line 48

 

Notice: Undefined index: state in /home/anodizi/public_html/image/upload2.php on line 92

 

Notice: Undefined index: part in /home/anodizi/public_html/image/upload2.php on line 103

 

Notice: Undefined index: description in /home/anodizi/public_html/image/upload2.php on line 104

 

Notice: Undefined index: spec in /home/anodizi/public_html/image/upload2.php on line 105

 

Notice: Undefined index: repeat_customer in /home/anodizi/public_html/image/upload2.php on line 106

 

Notice: Undefined index: isearch in /home/anodizi/public_html/image/upload2.php on line 107

 

Notice: Undefined index: trade in /home/anodizi/public_html/image/upload2.php on line 111

 

Notice: Undefined variable: burnish in /home/anodizi/public_html/image/upload2.php on line 114

 

<?php

error_reporting(E_ALL);

?>

<?php

$db_host = ''; 
$db_user = '; 
$db_pwd = '';

$database = ';
$table = '';


$upload_feedback = '';
var_dump($_FILES);



if (!mysql_connect($db_host, $db_user, $db_pwd))
    die("Can't connect to database");

if (!mysql_select_db($database))
    die("Can't select database");

$dest = 'upload/';

if(isset($_FILES) && !empty($_FILES) && is_array($_FILES))
{
    foreach($_FILES as $file)
    {
        $upload_msg[$file['name']] = move_upload($file, $dest);
    }
}


      function move_upload( $file, $dest, $overwrite = false )
    {
       
        if ($file["error"] == UPLOAD_ERR_OK)
        {
            if(!file_exists( $dest.$file["name"] ) || $overwrite)
            {
                if(move_uploaded_file( $file["tmp_name"], $dest.$file["name"] ))
                {
                    $upload_feedback .= "The file " . $file["name"] . " was successfully uploaded";
                    $error            = FALSE;
                }
                else
                {
                    $upload_feedback .= "The file " . $file["name"] . " could not be moved";
                    $error            = TRUE;
                }
            }
            else
            {
                $upload_feedback .= "The file " . $file["name"] . " already exists, please check the overwrite option if you wish to replace it";
                $error            = TRUE;
            }
        }
        else
        {
            switch ($file["error"])
            {
                case UPLOAD_ERR_INI_SIZE:
                case UPLOAD_ERR_FORM_SIZE:
                    $upload_feedback .= "The file " . $file["name"] . " is to large to be uploaded<br />";
                    $error            = TRUE;
                break;

                case UPLOAD_ERR_PARTIAL:
                    $upload_feedback .= "The file" . $file["name"] . " was interrupted while uploading, please try again<br />";
                    $error            = TRUE;
                break;
            }
        }

        return array( "error" => $error, "feedback" => $upload_feedback ); //return message plus error status
    }

?>
<?php
$f_1 = $_FILES['file1']['name'] ;
$f_2 = $_FILES['file2']['name'] ;
$customer = $_POST['customer'];
$company = $_POST['company'];
$address = $_POST['address'];
$city = $_POST['city'];
$zip = $_POST['zip'];
$state = $_POST['state'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$fax = $_POST['fax'];
$type2 = $_POST['type2'];
$type3 = $_POST['type3'];
$burnishing = $_POST['burnish'];
$chromate = $_POST['chromate'];
$hex = $_POST['hex'];
$impregnation = $_POST['impregnation'];
$strip = $_POST['strip'];
$part = $_POST['part'];
$description = $_POST['description'];
$spec = $_POST['spec'];
$repeat_customer = $_POST['repeat_customer'];
$isearch = $_POST['isearch'];
$internet_directory = $_POST['internet_directory'];
$referral = $_POST['referral'];
$yellow_pages = $_POST['yellow_pages'];
$trade = $_POST['trade'];
$other = $_POST['other'];
$notes = $_POST['notes'];
mysql_query("INSERT INTO ae_gallery (image1,image2,city,address,company,customer,state,email,phone,fax,type2,type3,burnish,chromate,hex,impregnation,strip,part,description,repeat_customer,isearch,internet_directory,referral,yellow_pages,trade,other,notes) VALUES('$f_1','$f_2','$city','$address','$company','$customer','$state','$email','$phone','$fax','$type2','$type3','$burnish','$chromate','$hex','$impregnation','$strip','$part','$description','$repeat_customer','$isearch','$internet_directory','$referral','$yellow_pages','$trade','$other','$notes')") or die(mysql_error());
?>

Link to comment
https://forums.phpfreaks.com/topic/113609-solved-undefined-index/
Share on other sites

$upload_feedback isn't defined in the scope of that function. Try:

      function move_upload( $file, $dest, $overwrite = false )
    {
        $upload_feedback = '';
        if ($file["error"] == UPLOAD_ERR_OK)
        {
            //....

 

Those indexes are supposed to be in the $_POST array, but since they aren't, I would think that your form isn't posting the values correctly.

thanks lemmin that took care of that error but still have these and these fields are not populating in the database?

 

Notice: Undefined index: state in /home/anodizi/public_html/image/upload2.php on line 90

 

Notice: Undefined index: zip_code in /home/anodizi/public_html/image/upload2.php on line 91

 

Notice: Undefined index: part in /home/anodizi/public_html/image/upload2.php on line 102

 

Notice: Undefined index: description in /home/anodizi/public_html/image/upload2.php on line 103

 

Notice: Undefined index: spec in /home/anodizi/public_html/image/upload2.php on line 106

 

Notice: Undefined index: repeat_customer in /home/anodizi/public_html/image/upload2.php on line 108

 

Notice: Undefined index: isearch in /home/anodizi/public_html/image/upload2.php on line 109

 

Notice: Undefined index: trade in /home/anodizi/public_html/image/upload2.php on line 113

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.