2013-02-06 40 views
1

我妈收到一个错误,指出:意外的T_Variable错误,是什么导致它在循环?

解析错误:语法错误,意想不到的T_VARIABLE ....线599

属于下面的一行:

foreach ($questions as $key=>$question) { 

    echo '<p><strong>Question:</strong> ' .htmlspecialchars($row_question['question_num'][$key]). ': ' .htmlspecialchars($row_question['question_content']$key]). '</p>' . PHP_EOL; 

    } 

我是什么做错了吗?

下面是代码:

$question = array(); 

    while ($selectedstudentanswerstmt->fetch()) { 

    $row_question = array(); 
    $row_question['question_num'] = $detailsQuestionNo; 
    $row_question['question_content'] = $detailsQuestionContent; 
    $row_question['question_option'] = $detailsOptionType; 
    $row_question['question_num_answers'] = $detailsNoofAnswers; 
    $row_question['question_answer'] = $detailsAnswer; 
    $row_question['questionnum_reply'] = $detailsReplyType; 
    $row_question['questionnum_marks'] = $detailsQuestionMarks; 
    $questions[] = $row_question; 
} 

................. 

<?php 

      foreach ($questions as $key=>$question) { 

echo '<p><strong>Question:</strong> ' .htmlspecialchars($row_question['question_num'][$key]). ': ' .htmlspecialchars($row_question['question_content']$key]). '</p>' . PHP_EOL; 

} 
?> 
+0

'$ row_question [ 'question_content'] $键]'应'$ row_question ['question_content'] [$ key]' –

回答

3

你缺少一个支架

echo '<p><strong>Question:</strong> ' .htmlspecialchars($row_question['question_num'][$key]). ': ' .htmlspecialchars($row_question['question_content']$key]). '</p>' . PHP_EOL; 

应该

echo '<p><strong>Question:</strong> ' .htmlspecialchars($row_question['question_num'][$key]). ': ' .htmlspecialchars($row_question['question_content'][$key]). '</p>' . PHP_EOL; 
+0

哦,上帝对不起,最好的答案,我可以快速问一个小问题,当我修正括号时,它输出只是问题内容的第一个字母,而不是question_num,是显示数组中信息的固定行吗? – user1914374

相关问题