sandbudd Posted July 7, 2008 Share Posted July 7, 2008 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 More sharing options...
craygo Posted July 7, 2008 Share Posted July 7, 2008 might be due to the fact you missed a single quote on line 10 and 13 $db_user = ''; $db_pwd = ''; $database = ''; try that and let us know Ray Link to comment https://forums.phpfreaks.com/topic/113609-solved-undefined-index/#findComment-583765 Share on other sites More sharing options...
sandbudd Posted July 7, 2008 Author Share Posted July 7, 2008 they are there on the original I just accidently deleted them when deleting the information. this is really strange as all the other fields populate the database fine except for those in the error? Link to comment https://forums.phpfreaks.com/topic/113609-solved-undefined-index/#findComment-583772 Share on other sites More sharing options...
lemmin Posted July 7, 2008 Share Posted July 7, 2008 $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. Link to comment https://forums.phpfreaks.com/topic/113609-solved-undefined-index/#findComment-583781 Share on other sites More sharing options...
sandbudd Posted July 7, 2008 Author Share Posted July 7, 2008 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 Link to comment https://forums.phpfreaks.com/topic/113609-solved-undefined-index/#findComment-583788 Share on other sites More sharing options...
lemmin Posted July 7, 2008 Share Posted July 7, 2008 Make sure your form is passing inputs with the correct names. Use print_r($_POST) to see all of the variables that got passed. Link to comment https://forums.phpfreaks.com/topic/113609-solved-undefined-index/#findComment-583812 Share on other sites More sharing options...
discomatt Posted July 7, 2008 Share Posted July 7, 2008 I use isset() before referencing any outside variables to prevent notice errors Link to comment https://forums.phpfreaks.com/topic/113609-solved-undefined-index/#findComment-583813 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.