如何将mysqli_result类的Object转换为String?

时间:2018-02-23 09:18:58

标签: php html sql localhost

我有这段代码:

$polaczenie = @new mysqli($host, $db_user, $db_password, $db_name); ...

... $result2 = mysqli_query($polaczenie, "SELECT money FROM roulette.users WHERE 
                                                        userSteamID='$SteamID'");
while($row = mysqli_fetch_assoc($result2)){
   print_r($row);
}

我得到了这个结果:Array ( [money] => 15 )

但我希望如此:var $money = 15

如何将mysqli_result类的Object转换为String?

我尝试了很多选项,例如thisthis

1 个答案:

答案 0 :(得分:1)

你可以试试这个:

$money;
while($row = mysqli_fetch_object($result2)){
   $money = $row->money;
}

echo $money;