一切正常,但现在发生了什么我不能说。实际上 mysql 不存储任何浮点值,并且所有其他值(例如整数、varchar 等)都可以接受。我发布了一部分代码。
在 .php 中查询
$que_cinstructors = "
INSERT INTO
course_instructors
( usn, i1, i2, i3, i4, i5, i6, i7, i8, i9 )
VALUES
( :usn, :i1, :i2, :i3, :i4, :i5, :i6, :i7, :i8, :i9 )";
$query_params3 = array( ':usn' => $_POST['usn'],
':i1' => $_POST['i1'],
':i2' => $_POST['i2'],
':i3' => $_POST['i3'],
':i4' => $_POST['i4'],
':i5' => $_POST['i5'],
':i6' => $_POST['i6'],
':i7' => $_POST['i7'],
':i8' => $_POST['i8'],
':i9' => $_POST['i9']
);
$statement3 = $db->prepare($que_cinstructors);
$result3 = $statement3->execute($query_params3);
$que_ccredits = "
INSERT INTO
course_credits
( usn, c1, c2, c3, c4, c5, c6, c7, c8, c9, total )
VALUES ( :usn, :c1, :c2, :c3, :c4, :c5, :c6, :c7, :c8, :c9, :total )";
$query_params4 = array( ':usn' => $_POST['usn'],
':c1' => $_POST['c1'],
':c2' => $_POST['c2'],
':c3' => $_POST['c3'],
':c4' => $_POST['c4'],
':c5' => $_POST['c5'],
':c6' => $_POST['c6'],
':c7' => $_POST['c7'],
':c8' => $_POST['c8'],
':c9' => $_POST['c9'],
':total' => $_POST['total']
);
$statement4 = $db->prepare($que_ccredits);
$result4 = $statement4->execute($query_params4);
从上面的两个查询第一个存储名称,它很好。但第二个是存储浮点值。在这里,我从会话变量中获取 usn。第一个插入很好,但第二个没有存储。
来自 .sql 的数据库
CREATE TABLE IF NOT EXISTS `course_instructors` (
`i_id` int(11) NOT NULL AUTO_INCREMENT,
`usn` varchar(7) NOT NULL,
`i1` varchar(50) NOT NULL,
`i2` varchar(50) NOT NULL,
`i3` varchar(50) NOT NULL,
`i4` varchar(50) NOT NULL,
`i5` varchar(50) NOT NULL,
`i6` varchar(50) NOT NULL,
`i7` varchar(50) NOT NULL,
`i8` varchar(50) NOT NULL,
`i9` varchar(50) NOT NULL,
PRIMARY KEY (`i_id`),
UNIQUE KEY `usn` (`usn`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=5 ;
CREATE TABLE IF NOT EXISTS `course_credits` (
`c_id` int(11) NOT NULL AUTO_INCREMENT,
`usn` varchar(7) NOT NULL,
`c1` float NOT NULL,
`c2` float NOT NULL,
`c3` float NOT NULL,
`c4` float NOT NULL,
`c5` float NOT NULL,
`c6` float NOT NULL,
`c7` float NOT NULL,
`c8` float NOT NULL,
`c9` float NOT NULL,
`total` float NOT NULL,
PRIMARY KEY (`c_id`),
UNIQUE KEY `usn` (`usn`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;
一切正常。我正在与项目的其他部分合作,今天当我尝试提交时,我遇到了这个问题。这让我发疯了......请帮助并且文本字段名称是正确的。