如何显示mysql_query中的值或将其保存在一个变量中?目前我得到的是资源id #4。
$currentpointsquery = "SELECT user_points FROM points WHERE user_id = '$user_id';";
$currentpointsquery2 = mysql_query($currentpointsquery);
echo(currentpointsquery2);
echo($currentpointsquery2);
这里你试图打印一个 mysql 资源变量 而不是它所引用的资源中的值。该 mysql_fetch_array()
函数以关联数组或数字数组的形式从记录集中返回一行。所以可以尝试用
echo $currentpoints[0];
或
echo $currentpoints['user_points'];
试试吧
$currentpointsquery = "SELECT user_points FROM points WHERE user_id = '$user_id'";
$currentpointsquery2 = mysql_query($currentpointsquery);
$currentpoints = mysql_fetch_array($currentpointsquery2);
echo $currentpoints['user_points'];