提交到数据库的申请表有时是有效的,有时则不然

时间:2013-05-17 13:42:45

标签: php sql insert

这是一个将所有字段提交到数据库的申请表。有时它完美没有任何问题,有时一切都提交,但上传的文件不包括在内,有时根本没有输入数据库。我已经尝试了所有随机测试条目,无法找出触发失败的内容,并且无法在我的代码中看到它。任何帮助将不胜感激,谢谢!

if ((($_FILES["file"]["type"] == "application/msword") || ($_FILES["file"]["type"] == "application/vnd.openxmlformats-officedocument.wordprocessingml.document") || ($_FILES["file"]["type"] == "application/pdf") || ($_FILES["file"]["type"] == "text/plain")) && ($_FILES["file"]["size"] < 10485760)){

        if ($_FILES["file"]["error"] > 0){
            echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
        } else {
            $filename = $_FILES["file"]["name"];
            $file_basename = substr($filename, 0, strripos($filename, '.')); // get file extention
            $file_ext = substr($filename, strripos($filename, '.')); // get file name

            $uniquename = $timestamp.$file_basename;

            $newfilename = md5($uniquename) . $file_ext;

            if (file_exists("$setting[upload_apps]" . $newfilename)) {
                 echo "You have already uploaded this file.";
            } else {
                move_uploaded_file($_FILES["file"]["tmp_name"], "$setting[upload_apps]" . $newfilename);
                $target_path = "/files/";
                $target_path = $target_path . $newfilename;

                mysql_query("INSERT INTO career_apps (position, email, fname, lname, address1, address2, city, state, zip, phone, cell, cemployed, layoff, proof, priorapp, appdate, prioremploy, prioremploydate, availdate, convict, convictdetails, school, school_study, school_years, school_degree, college, college_study, college_years, college_degree, grad, grad_study, grad_years, grad_degree, certs, employer1, employer1_address, employer1_telephone, employer1_title, employer1_supervisor, employer1_from, employer1_to, employer1_salary, employer1_duties, employer1_reason, employer2, employer2_address, employer2_telephone, employer2_title, employer2_supervisor, employer2_from, employer2_to, employer2_salary, employer2_duties, employer2_reason, employer3, employer3_address, employer3_telephone, employer3_title, employer3_supervisor, employer3_from, employer3_to, employer3_salary, employer3_duties, employer3_reason, resume_file, resume, sig1, date1, sig2, date2, ip, submitted) VALUES ('$_POST[id]', '$_POST[email]', '$_POST[fname]', '$_POST[lname]', '$_POST[address1]', '$_POST[address2]', '$_POST[city]', '$_POST[state]', '$_POST[zip]', '$_POST[phone]', '$_POST[cell]', '$_POST[cemployed]', '$_POST[layoff]', '$_POST[proof]', '$_POST[priorapp]', '$_POST[appdate]', '$_POST[prioremploy]', ''$_POST[prioremploydate]', '$_POST[availdate]', '$_POST[convict]', '$_POST[convictdetails]', '$_POST[school]', '$_POST[school_study]', '$_POST[school_years]', '$_POST[school_degree]', '$_POST[college]', '$_POST[college_study]', '$_POST[college_years]', '$_POST[college_degree]', '$_POST[grad]', '$_POST[grad_study]', '$_POST[grad_years]', '$_POST[grad_degree]', '$_POST[certs]', '$_POST[employer1]', '$_POST[employer1_address]', '$_POST[employer1_telephone]', '$_POST[employer1_title]', '$_POST[employer1_supervisor]', '$_POST[employer1_from]', '$_POST[employer1_to]', '$_POST[employer1_salary]', '$_POST[employer1_duties]', '$_POST[employer1_reason]', '$_POST[employer2]', '$_POST[employer2_address]', '$_POST[employer2_telephone]', '$_POST[employer2_title]', '$_POST[employer2_supervisor]', '$_POST[employer2_from]', '$_POST[employer2_to]', '$_POST[employer2_salary]', '$_POST[employer2_duties]', '$_POST[employer2_reason]', '$_POST[employer3]', '$_POST[employer3_address]', '$_POST[employer3_telephone]', '$_POST[employer3_title]', '$_POST[employer3_supervisor]', '$_POST[employer3_from]', '$_POST[employer3_to]', '$_POST[employer3_salary]', '$_POST[employer3_duties]', '$_POST[employer3_reason]', '$target_path', '$_POST[resume]', '$_POST[sig1]', '$_POST[date1]', '$_POST[sig2]', '$_POST[date2]', '$ip', '$time')");
                if ($query) {
                echo"<p align='center'><span class='warning'>CONFIRMATION!</span></p>$app_success";
                }
            }
        }
    } else {
        mysql_query("INSERT INTO career_apps (position, email, fname, lname, address1, address2, city, state, zip, phone, cell, cemployed, layoff, proof, priorapp, appdate, prioremploy, prioremploydate, availdate, convict, convictdetails, school, school_study, school_years, school_degree, college, college_study, college_years, college_degree, grad, grad_study, grad_years, grad_degree, certs, employer1, employer1_address, employer1_telephone, employer1_title, employer1_supervisor, employer1_from, employer1_to, employer1_salary, employer1_duties, employer1_reason, employer2, employer2_address, employer2_telephone, employer2_title, employer2_supervisor, employer2_from, employer2_to, employer2_salary, employer2_duties, employer2_reason, employer3, employer3_address, employer3_telephone, employer3_title, employer3_supervisor, employer3_from, employer3_to, employer3_salary, employer3_duties, employer3_reason, resume, sig1, date1, sig2, date2, ip, submitted) VALUES ('$_POST[id]', '$_POST[email]', '$_POST[fname]', '$_POST[lname]', '$_POST[address1]', '$_POST[address2]', '$_POST[city]', '$_POST[state]', '$_POST[zip]', '$_POST[phone]', '$_POST[cell]', '$_POST[cemployed]', '$_POST[layoff]', '$_POST[proof]', '$_POST[priorapp]', '$_POST[appdate]', '$_POST[prioremploy]', '$_POST[prioremploydate]', '$_POST[availdate]', '$_POST[convict]', '$_POST[convictdetails]', '$_POST[school]', '$_POST[school_study]', '$_POST[school_years]', '$_POST[school_degree]', '$_POST[college]', '$_POST[college_study]', '$_POST[college_years]', '$_POST[college_degree]', '$_POST[grad]', '$_POST[grad_study]', '$_POST[grad_years]', '$_POST[grad_degree]', '$_POST[certs]', '$_POST[employer1]', '$_POST[employer1_address]', '$_POST[employer1_telephone]', '$_POST[employer1_title]', '$_POST[employer1_supervisor]', '$_POST[employer1_from]', '$_POST[employer1_to]', '$_POST[employer1_salary]', '$_POST[employer1_duties]', '$_POST[employer1_reason]', '$_POST[employer2]', '$_POST[employer2_address]', '$_POST[employer2_telephone]', '$_POST[employer2_title]', '$_POST[employer2_supervisor]', '$_POST[employer2_from]', '$_POST[employer2_to]', '$_POST[employer2_salary]', '$_POST[employer2_duties]', '$_POST[employer2_reason]', '$_POST[employer3]', '$_POST[employer3_address]', '$_POST[employer3_telephone]', '$_POST[employer3_title]', '$_POST[employer3_supervisor]', '$_POST[employer3_from]', '$_POST[employer3_to]', '$_POST[employer3_salary]', '$_POST[employer3_duties]', '$_POST[employer3_reason]', '$_POST[resume]', '$_POST[sig1]', '$_POST[date1]', '$_POST[sig2]', '$_POST[date2]', '$ip', '$time')");
                if ($query) {
                echo"<p align='center'><span class='warning'>CONFIRMATION!</span></p>$app_success";
                }
    }

1 个答案:

答案 0 :(得分:0)

我遇到了文件大小限制的问题。如果您将.htaccess文件添加到您的网站路由目录,您应该能够解决问题:

memory_limit = 100M
upload_max_filesize = 50M
post_max_size = 50M

http://www.cyberciti.biz/faq/linux-unix-apache-increase-php-upload-limit/

另外你可以改变php.ini文件。

http://drupal.org/node/97193

我过去曾使用.htaccess,因为当我将网站上传到主机时,我无法访问php.ini。