注意:数组到字符串的转换 [英] Notice: Array to string conversion in
本文介绍了注意:数组到字符串的转换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试从数据库中选择一个值并使用 SELECT 将其显示给用户.但是我不断收到此错误:
I'm trying to select a value from a database and display it to the user using SELECT. However I keep getting this error:
Notice: Array to string conversion in (pathname) on line 36.
我认为 @mysql_fetch_assoc();
会解决这个问题,但我仍然收到通知.这是我收到错误的代码部分:
I thought that the @mysql_fetch_assoc();
would fix this but I still get the notice. This is the part of the code where I'm getting the error:
{
$loggedin = 1;
$get = @mysql_query("SELECT money FROM players WHERE username =
'$_SESSION[username]'");
$money = @mysql_fetch_assoc($get);
echo '<p id= "status">'.$_SESSION['username'].'<br>
Money: '.$money.'.
</p>';
}
我做错了什么?我对 PHP 还很陌生.
What am I doing wrong? I'm pretty new to PHP.
推荐答案
问题在于 $money 是一个数组,而您将其视为字符串或可以轻松转换为字符串的变量.你应该这样说:
The problem is that $money is an array and you are treating it like a string or a variable which can be easily converted to string. You should say something like:
'.... Money:'.$money['money']
这篇关于注意:数组到字符串的转换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文