我想在MySQL replace语句中使用一个数组中的值作为另一个数组的键。我尝试了下面的代码,但发现语法错误

"Unexpected '[' expected ']'"

如果可以的话,我们将非常感谢您对正确语法的帮助。
$sql = "REPLACE INTO sections(IDENTIFIER, NAME, DESCRIPTION, SEQUENCE, INSTRUCTIONS, TIME_AVAILABLE, EXTERNAL_RESOURCE)
            VALUES ('$currentline[$flippedheaders['IDENTIFIER']]', '$currentline[flippedheaders['NAME']]', '$currentline[flippedheaders['DESCRIPTION']]', $currentline[flippedheaders['SEQUENCE']], '$currentline[flippedheaders['INSTRUCTION']]', $currentline[flippedheaders['TIME_AVAILABLE']], '$currentline[flippedheaders['EXTERNAL_RESOURCE']]')";

最佳答案

我看到你有很多错别字,错误的引号和没有正确插入字符串。尝试如下:

$sql = "REPLACE INTO sections(IDENTIFIER, NAME, DESCRIPTION, SEQUENCE, INSTRUCTIONS, TIME_AVAILABLE, EXTERNAL_RESOURCE)
        VALUES ('{$currentline[$flippedheaders['IDENTIFIER']]}', '{$currentline[$flippedheaders['NAME']]}', '{$currentline[$flippedheaders['DESCRIPTION']]}', '{$currentline[$flippedheaders['SEQUENCE']]}, '{$currentline[$flippedheaders['INSTRUCTION']]}', '{$currentline[$flippedheaders['TIME_AVAILABLE']]}', '{$currentline[$flippedheaders['EXTERNAL_RESOURCE']]}')";

10-04 20:25