我试图在我的网站上添加用户关注功能,例如twitter' s但我一直在收到此错误
警告:mysqli_fetch_object()期望参数1为
mysqli_result,给出的字符串 /应用/ XAMPP / xamppfiles / htdocs中/ ftbindex ....
这是我的代码,请问有什么问题吗?
<?php
// show users function
function show_users(){
$users=array();
$sql="SELECT user_id,username FROM users ORDER BY username DESC"; while($data=mysqli_fetch_object($sql)){
$users[$data->user_id] = $data->username;
}
return $users;
}
?>
//end of show users function
//begin display of users in a table
<?php
$users= show_users();
if (count($users)){
?>
<table border='1' cellspacing='0' cellpadding='5' width='500'>
<?php
foreach ($users as $key => $value){
echo "<tr valign='top'>\n";
echo "<td>".$key ."</td>\n";
echo "<td>".$value ." <small><a href='#'>follow</a></small></td>\n";
echo "</tr>\n";
}
?>
</table>
<?php
}else{
?>
<p><b>There are no users in the system!</b></p>
<?php
}
?>
//end