如何显示mysql_query中的值或将值保存在变量中?目前我获得资源ID#4。
$currentpointsquery = "SELECT user_points FROM points WHERE user_id = '$user_id';";
$currentpointsquery2 = mysql_query($currentpointsquery);
echo(currentpointsquery2);
答案 0 :(得分:1)
试一试:
$currentpointsquery = "SELECT user_points FROM points WHERE user_id = '$user_id'";
$currentpointsquery2 = mysql_query($currentpointsquery);
$currentpoints = mysql_fetch_array($currentpointsquery2);
echo $currentpoints['user_points'];
答案 1 :(得分:0)
echo($currentpointsquery2);
在这里,您尝试打印mysql resource variable,而不是它引用的资源中包含的值。 mysql_fetch_array()
函数从记录集返回一行作为关联数组和/或数字数组。所以试试
echo $currentpoints[0];
或
echo $currentpoints['user_points'];