解析错误:语法错误,意外''''(T_CONSTANT_ENCAPSED_STRING),期待','或';'在

时间:2013-05-31 16:25:59

标签: php html sql row echo

我不断收到echo语句的错误。报价是错误的吗?我应该在$ row语句周围添加引号

<?php
    while($row = mysql_fetch_array($search))
      {
      echo "<tr>"//the line below
       '<td>' . $row['DepartmentOwner'] . '</td>';
       '<td>' . $row['CurrentAssignee'] . '</td>';
       '<td>' . $row['Location'] . '</td>';
       '<td>' . $row['LaptopSerialNumber'] . '</td>';
       '<td>' . $row['SupportedOS'] . '</td>';
       '<td>' . $row['DeviceName'] . '</td>';
       '<td>' . $row['IMEISerialNumber'] . '</td>';
       '<td>' . $row['UUID'] . '</td>';
       '<td>' . $row['ReturnDate']'</td>';
       "</tr>";
      }
      echo "</table>"; ?>

3 个答案:

答案 0 :(得分:2)

在这一行

'<td>' . $row['ReturnDate']'</td>'

应该是

'<td>' . $row['ReturnDate'] . '</td>'

您缺少字符串连接符.

while($row = mysql_fetch_array($search)){
    echo "<tr>";
    echo '<td>' . $row['DepartmentOwner'] . '</td>';
    echo '<td>' . $row['CurrentAssignee'] . '</td>';
    echo '<td>' . $row['Location'] . '</td>';
    echo '<td>' . $row['LaptopSerialNumber'] . '</td>';
    echo '<td>' . $row['SupportedOS'] . '</td>';
    echo '<td>' . $row['DeviceName'] . '</td>';
    echo '<td>' . $row['IMEISerialNumber'] . '</td>';
    echo '<td>' . $row['UUID'] . '</td>';
    echo '<td>' . $row['ReturnDate'] . '</td>';
    echo "</tr>";
}
echo "</table>"; ?>

答案 1 :(得分:0)

如果你关闭你的回声,你需要再次写回声!

<?php
while($row = mysql_fetch_array($search))
  {
    echo "<tr>";//the line below
    echo '<td>' . $row['DepartmentOwner'] . '</td>';
    echo '<td>' . $row['CurrentAssignee'] . '</td>';
    echo '<td>' . $row['Location'] . '</td>';
    echo '<td>' . $row['LaptopSerialNumber'] . '</td>';
    echo '<td>' . $row['SupportedOS'] . '</td>';
    echo '<td>' . $row['DeviceName'] . '</td>';
    echo '<td>' . $row['IMEISerialNumber'] . '</td>';
    echo '<td>' . $row['UUID'] . '</td>';
    echo '<td>' . $row['ReturnDate'].'</td>';
    echo "</tr>";
  }
  echo "</table>"; ?>

答案 2 :(得分:0)

你错误地将传递给echo的字符串连接起来,你可以使用PHP的alternate syntax来避免这种情况(并使代码更加清晰)。

<?php while($row = mysql_fetch_array($search)): ?>
    <tr>
        <td><?php echo $row['DepartmentOwner']; ?></td>
        <td><?php echo $row['CurrentAssignee']; ?></td>
        <td><?php echo $row['Location']; ?></td>
        ...
        ...
        ...
    </tr>
<?php endwhile; ?>

安东尼。