【发布时间】:2014-09-26 11:59:37
【问题描述】:
我一直在做一个 PHP 项目,我在一个文件中遇到错误,即
解析错误:语法错误、意外的 '' (T_ENCAPSED_AND_WHITESPACE)、需要标识符 (T_STRING) 或变量 (T_VARIABLE) 或数字 (T_NUM_STRING) 在 C:\xampp\htdocs\simple\directory.php 第 91 行
我的代码是:
$s = mysql_query("select * from user_reg where mid='$mid'");
$f = mysql_fetch_array($s);
<?php
while($f = mysql_fetch_array($s))
{ echo "
<div class='divtable'>
<table border='0' cellspacing='10px'>
<tr><td rowspan='4' align='center'><img src='user/$imgsrc' alt='$name' height='100px' width='100px' border='0' title=$name' /></td><th>Name</th><td><?php echo $f['name'];?></td></tr>
<tr><th>Specialized In</th><td><?php echo $f['spl'];?></td></tr>
<tr><th>Degrees</th><td><?php echo $f['de'];?></td></tr>
</table>
</div>";
}
?>
在这里,我正在从 MySql 数据库中检索图像的来源。 我也曾尝试通过使用 heredoc 语法来解决这个问题。
<?php
while($f = mysql_fetch_array($s))
{ echo <<<abc
<div class='divtable'>
<table border='0' cellspacing='10px'>
<tr><td rowspan='4' align='center'><img src='user/$imgsrc' alt='$name' height='100px' width='100px' border='0' title=$name' /></td><th>Name</th><td>$f['name']</td></tr>
<tr><th>Specialized In</th><td>$f['spl']</td></tr>
<tr><th>Degrees</th><td>$f['de']</td></tr>
</table>
</div>";
abc;
}
?>
但错误与上述相同..
请帮我解决这个问题
我正在使用这个 while 循环在我的网站上显示我的用户的详细信息,包括照片,是否有任何与 while 相同的循环来完成我的工作。
在此先感谢...
【问题讨论】:
-
错误信息说问题出在第 91 行。那是你代码的哪一行?
-
$s = mysql_query("select * from user_reg where mid='$mid'"); $f = mysql_fetch_array($s); <?php ...- 这是您的实际代码吗?另外,您的abc;前面有空格吗? 非常重要。 -
@Ghost - 您删除了 OP 代码中
abc;之前的空格(在编辑中),这可能是 OP 代码的错误之一。我做了一个回滚。编辑代码时请小心。这可能会影响我的回答。
标签: php html mysql while-loop heredoc