IE
$result = MysqL_query ("INSERT INTO module_evaluation_results
(faculty, date, modulecode, moduletitle, school, modulebookcontent, moduleorganisation, lrcmaterials, moduledifficulty. modulesimilarity,
contentinteresting, prevIoUskNowledge, understoodassessmentrequirements, assessmentmethod, moduleleader, ML_interestforsubject, ML_contentclear,
ML_appropriateteachingpace,ML_reachableforadvice, ML_helpfulFeedback, lecturer1, L1_interestforsubject, L1_contentclear,
L1_appropriateteachingpace, L1_reachableforadvice, L1_helpfulFeedback, lecturer2, L2_interestforsubject, L2_contentclear, L2_appropriateteachingpace,
L2_reachableforadvice, L2_helpfulFeedback, hoursofindependentstudy, overallattendance, bestfeaturesofmodule, improvemodule)
VALUES ($faculty, $date, $modulecode, $moduletitle, $school, $modulebookcontent, $moduleorganisation, $lrcmaterials, $moduledifficulty,
$modulesimilarity, $contentinteresting, $prevIoUskNowledge, $understoodassessmentrequirements, $assessmentmethod, $moduleleader,
$ML_interestforsubject, $ML_contentclear, $ML_appropriateteachingpace, $ML_reachableforadvice, $ML_helpfulFeedback, $lecturer1, $L1_interestforsubject,
$L1_contentclear, $L1_appropriateteachingpace, $L1_reachableforadvice,
$L1_helpfulFeedback, $lecturer2, $L2_interestforsubject,
$L2_contentclear, $L2_appropriateteachingpace, $L2_reachableforadvice,
$L2_helpfulFeedback, $hoursofindependentstudy,
$overallattendance, $bestfeaturesofmodule, $improvemodule)");
这个函数是ddlshack在PHP.net上的http://au2.php.net/mysql_query我已经在本地对其进行了一些更改以反映您的用例进行测试,并且它的工作正常,也许它也将有助于简化您的插入调用
function MysqL_insert($table, $inserts)
{
$values = array_map('MysqL_real_escape_string', array_values($inserts));
$keys = array_keys($inserts);
return MysqL_query('INSERT INTO `'.$table.'` (`'.implode('`,`', $keys).'`) VALUES (\''.implode('\',\'', $values).'\')');
}
像这样使用;
MysqL_insert(
'module_evaluation_results', array(
'col1' => rand(10,100),
'col2' => 'string1',
'col3' => 'string2',
'col4' => rand(10,100),
'col5' => 'string3',
));
所以MysqL_insert(表名,数组(列名,值));
$link = MysqL_connect('127.0.0.1:3306', 'test-user', 'test-pass');
if (!$link) {
die('Could not connect: ' . MysqL_error());
}
echo 'Connected successfully';
$db_selected = MysqL_select_db("test", $link);
if (!$db_selected)
{
die("Could not use the database");
};
MysqL_insert(
'module_evaluation_results', array(
'col1' => rand(10,100),
'col2' => 'string1',
'col3' => 'string2',
'col4' => rand(10,100),
'col5' => 'string3',
));
MysqL_close($link);
function MysqL_insert($table, $inserts)
{
$values = array_map('MysqL_real_escape_string', array_values($inserts));
$keys = array_keys($inserts);
return MysqL_query('INSERT INTO `'.$table.'` (`'.implode('`,`', $keys).'`) VALUES (\''.implode('\',\'', $values).'\')');
}
我认为问题可能出在您的表格名称上?加上写的查询的复杂性可能是一些错字,但是此代码一定可以多次执行插入操作,并且如果有帮助,则更易于阅读和编写代码