0

以下查询语句可以从 MySQL 命令行执行我想要的操作,但我希望也可以在网页上获取结果。这是我为此写的,但我只收到错误 45。

    table colspan="1" align="center" VALIGN="top" border="2" cellspacing = "0" cellpadding     = "5">
<td>
<?php    
$query  = "SELECT concat(firstname, ' ', lastname) AS 'Online Users' FROM opensim.GridUser 
INNER JOIN opensim.UserAccounts ON opensim.UserAccounts.PrincipalID = opensim.GridUser.UserID  WHERE opensim.GridUser.online = 'true';
";
$result = mysql_query($query);
while ($row    = mysql_fetch_assoc($result));
echo $result ?>
<br><br><br>
When programed this page should show
<br>Grid Users Online Names <br>



 <br><br></td>
 </table>

任何帮助将不胜感激。

4

2 回答 2

1

删除单引号

尝试这个:

$query  = "SELECT concat(firstname, ' ', lastname) AS Online_Users FROM opensim.GridUser 
INNER JOIN opensim.UserAccounts ON opensim.UserAccounts.PrincipalID = opensim.GridUser.UserID  WHERE opensim.GridUser.online = 'true';
";
于 2013-09-26T15:35:49.997 回答
0

你有一个错字。应该是这样的:

while ($row = mysql_fetch_assoc($result)) {
    echo $row['Online_Users']."<br>";
}
?>
于 2013-09-26T15:54:34.043 回答