dstjh46606 2012-10-23 06:19
浏览 38
已采纳

PHP SQL查询错误22仅在插入时找不到文件

I'm creating a website that inserts data into an db. It can pull all the data out of the db with no problem, but somehow it goes wrong when I insert the data.

This is the part that gets the values and make the query and execute the query:

    $facility_id = $_POST['facilityID'];
    $location_zone_area = $_POST['locationZoneArea'];
    $facility_type = $_POST['facilityType'];
    $structure_type = $_POST['structureType'];
    $material_type = $_POST['materialType'];
    $cause_of_defect = $_POST['causeOfDefect'];
    $defect_outcome = $_POST['defectOutcome'];
    $repair_strategy = $_POST['repairStrategy'];
    $defect_description = $_POST['defectDescription'];
    $defect_condition = $_POST['defectCondition'];
    $likelihood_of_failure = $_POST['likelihoodOfFailure'];
    $consequence_of_failure = $_POST['consequenceOfFailure'];
    $value = $_POST['value'];
    $risk = $_POST['risk'];
    $inspection_frequency = $_POST['inspectionFrequency'];
    $remarks = $_POST['remarks'];
    $structure_plan = $_POST['structurePlan'];
    $name_of_supervisor = $_POST['nameOfSupervisor'];
    $date = $_POST['date'];
    $email = $_POST['email'];

    $sQueryInsertData = "   INSERT INTO `
                            ".DB_PREFIX."main` 
                            (`facility_id`,`location_zone_area`,`structure_type`,`material_type`,`cause_of_defect`,`defect_outcome`,`repair_strategy`,`defect_description`,`defect_condition`,`likelihood_of_failure`,`consequence_of_failure`,`value`,`risk`,`inspection_frequency`,`remarks`,`structure_plan`,`name_of_supervisor`,`date`,`email`,`facility_type`) VALUES ('$facility_id','$location_zone_area','$structure_type','$material_type','$cause_of_defect','$defect_outcome','$repair_strategy','$defect_description','$defect_condition','$likelihood_of_failure','$consequence_of_failure','$value','$risk','$inspection_frequency','$remarks','$structure_plan','$name_of_supervisor','$date', '$email','$facility_type')";
    $insertSuccesfull = do_query($sQueryInsertData,'INSERT');

The do_query:

function do_query($le_query_to_execute, $type_to_do) {
    global $link2;
    switch ($type_to_do) {
        case 'SELECT' :
            $return_value = mysqli_query($link2,$le_query_to_execute) or die(mysqlError($le_query_to_execute, mysqli_error($link2)));
            return $return_value;
            break;
        case 'UPDATE' :
            if (mysqli_query($link2,$le_query_to_execute) or die(mysqlError($le_query_to_execute, mysqli_error($link2)))) {
                return TRUE;
            }
            break;
        case 'DELETE' :
            if (mysqli_query($link2,$le_query_to_execute) or die(mysqlError($le_query_to_execute, mysqli_error($link2)))) {
                return TRUE;
            }
            break;
        case 'INSERT' :
            if (mysqli_query($link2,$le_query_to_execute) or die(mysqlError($le_query_to_execute, mysqli_error($link2)))) {
                return TRUE;
            }
            break;
        default :
            mysqlError($le_query_to_execute,'Er is geen keuze gemaakt wat voor soort type query het is.');
            return FALSE;
            break;
    }
    return FALSE;
}

And the error i get:

There is an error in the query:

INSERT INTO ` facilitydb_main` (`facility_id`,`location_zone_area`,`structure_type`,`material_type`,`cause_of_defect`,`defect_outcome`,`repair_strategy`,`defect_description`,`defect_condition`,`likelihood_of_failure`,`consequence_of_failure`,`value`,`risk`,`inspection_frequency`,`remarks`,`structure_plan`,`name_of_supervisor`,`date`,`email`,`facility_type`) VALUES ('mcot','nederland / hiero / daar','Administration','Concrete','Low cement content and finely ground cement','Highly permeable concrete','Repair','Defect descri','Lighthouse.jpg','2','1','2','Very Low','Inspection/maintenance in a maximum of 5 years’ time','kaput','Hydrangeas1.jpg','Marc MEesters','now', 'abcdingetje@gmail.com','building')

This is the error mysqli gave: 
Can't find file: '.\facilitydb2test\@000d@000a@0009@0009@0009@0009@0009@0009@0009facilitydb_main.frm' (errno: 22)

Data of the table facility_main:

CREATE TABLE `facilitydb_main` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `facility_id` text NOT NULL,
  `location_zone_area` text NOT NULL,
  `structure_type` text NOT NULL,
  `material_type` text NOT NULL,
  `cause_of_defect` text NOT NULL,
  `defect_outcome` text NOT NULL,
  `repair_strategy` text NOT NULL,
  `defect_description` text NOT NULL,
  `defect_condition` text NOT NULL,
  `likelihood_of_failure` int(11) NOT NULL,
  `consequence_of_failure` int(11) NOT NULL,
  `value` int(11) NOT NULL,
  `risk` text NOT NULL,
  `inspection_frequency` text NOT NULL,
  `remarks` text NOT NULL,
  `structure_plan` text NOT NULL,
  `name_of_supervisor` text NOT NULL,
  `date` text NOT NULL,
  `email` text NOT NULL,
  `facility_type` text,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  • 写回答

1条回答 默认 最新

  • dsplos5731 2012-10-23 06:35
    关注

    Try

    REPAIR TABLE facilitydb_main;
    

    Edit INSERT INTO facilitydb_main should be INSERT INTO facilitydb_main (no space)

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 求差集那个函数有问题,有无佬可以解决
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题