那只是我的php片段:
$cookies=$_COOKIE['rwt'];
$user =mysql_query("SELECT user FROM users WHERE cookies='$cookies'");
如何从MySQL表中直接检索数据$ user?现在我得到了奇怪的结果:资源ID#10
答案 0 :(得分:3)
您必须从结果句柄中获取一行:
$user = mysql_query(blah blah blah);
$row = mysql_fetch_assoc($user);
echo $row['user'];
答案 1 :(得分:1)
如果没有获取数组,您可以使用mysql_result();
获取单个列值$cookies=mysql_real_escape_string($_COOKIE['rwt']);
$userResource =mysql_query("SELECT user FROM users WHERE cookies='{$cookies}'");
$user=mysql_result($userResource,0,"user");