Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/74.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP SQL查询错误22仅在插入时未找到文件_Php_Sql_Database_Mysqli - Fatal编程技术网

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

PHP SQL查询错误22仅在插入时未找到文件,php,sql,database,mysqli,Php,Sql,Database,Mysqli,我正在创建一个将数据插入数据库的网站。它可以毫无问题地将所有数据从数据库中取出,但是当我插入数据时,它不知何故出错了 这是获取值、进行查询并执行查询的部分: $facility_id = $_POST['facilityID']; $location_zone_area = $_POST['locationZoneArea']; $facility_type = $_POST['facilityType']; $structure_type = $_POST['s

我正在创建一个将数据插入数据库的网站。它可以毫无问题地将所有数据从数据库中取出,但是当我插入数据时,它不知何故出错了

这是获取值、进行查询并执行查询的部分:

    $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');
do_查询:

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;
}
我得到的错误是:

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)
表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;
试一试

编辑
INSERT INTO
facilitydb\u main
应插入
facilitydb\u main
(无空格)

您是否检查了mysql用户对.frm文件的写入权限是否正确?@janenz00我正在使用wamp(如果需要的话),我可以在其他数据库中添加信息。。。我向列表中的每个人添加了所有权限(mysql中的地图数据和地图设施数据库),并添加了一个用户everyone,该用户也具有所有权限,但仍然没有运气……当我这样做时,我收到了这样一条消息:
表的存储引擎不支持修复
是的,因为它是InnoDB。尝试转换为MyISAM“ALTER TABLE facilitydb_主机=MyISAM;“,修复它并查看查询是否有效?好的,完成了。现在修复显示消息ok,但执行查询时仍然没有运气…修复没有输出错误,只是ok。执行查询时仍然会出现相同的错误…嗯…插入'facilitydb____________________________________________
REPAIR TABLE facilitydb_main;