mysql_fetch_array返回一个数组,因此您需要选择所需数组的位:
$row = mysql_fetch_array($query); $data=unserialize($row['friends']);
你也应该养成检查错误的习惯,例如
$result = mysql_query("SELECT friends FROM users WHERE id='$myid'"); if ($result) { if ($row = mysql_fetch_array($result)) { $data=unserialize($row['friends']); } else { //empty result, set up empty data? $data=array(); } } else { die('Invalid query: ' . mysql_error()); }