解析错误:语法错误,意外的 T_ECHO [英] Parse error: syntax error, unexpected T_ECHO
本文介绍了解析错误:语法错误,意外的 T_ECHO的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
过去几天我一直在做一些事情,但是这段代码总是会引发意想不到的 T_ECHO.我的朋友们似乎找不到任何问题,而我正处于耐心的边缘.即使删除了嵌套的 while 循环,它仍然会引发错误,我切换到 while: endwhile;语法也是如此,我仍然得到它.我确信答案正盯着我的脸,但我可能看不到.
I've been working on something for the past few days but this one bit of code perpetually throws an unexpected T_ECHO. My friends can't seem to find anything wrong with it and I'm at the edge of my patience. Even with the nested while loop removed it still throws an error and I switched to the while: endwhile; syntax as well and I'm still getting it. I'm sure the answer is staring me in the face but I probably can't see it.
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)):
echo "<tr>";
echo "<td>". $row["site_description"] ."</td>";
echo "<td>". $row["url"] ."</td>";
echo "<td><select>";
while ($roar = mysql_fetch_array($categories, MYSQL_ASSOC)):
echo "<option value=\"". $roar["category"] ."\">". $roar["category"] ."</option>";
endwhile;
echo "</select></td>";
echo "</tr>";
endwhile;
推荐答案
您可以使用短标签来提高可读性并减少出错的可能性.
You could use short tags to make this far more readable and likely less error prone.
<?php while ($row = mysql_fetch_array($result, MYSQL_ASSOC)): ?>
<tr>
<td><?= $row["site_description"] ?></td>
<td><?= $row["url"] ?></td>
<td>
<select>
<?php while ($roar = mysql_fetch_array($categories, MYSQL_ASSOC)): ?>
<option><?= $roar["category"] ?></option>
<?php endwhile; ?>
</select>
</td>
</tr>
<?php endwhile; ?>
这篇关于解析错误:语法错误,意外的 T_ECHO的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文