过去一天,这个问题一直困扰着我。这是代码:
public function getUserCredits()
{
$dbl = new databaseManager();
$dbl->connect_simp();
$ret = $dbl->queryDB("SELECT * FROM users WHERE `USER_ID` = ".$this->userId);
$this->userCredits = $ret['USER_CREDITS'];
return $this->userCredits;
}
现在,当我尝试运行此代码时,出现undefined offset
错误。当我第一次看到它时并没有什么奇怪的,但现在它越来越多地发生了,我不知道为什么。
我可以使用它var_dump();
,var_export();
它可以很好地显示返回数组的内容。
编辑:
array(1) {
[0]=>
array(50) {
["USER_ID"]=>
string(10) "0000000001"
[0]=>
string(10) "0000000001"
["USER_USERNAME"]=>
string(8) "SampleUsername"
[1]=>
string(8) "SampleUsername"
["USER_PASSWORD"]=>
string(32) "5f4dcc3b5aa765d61d8327deb882cf99"
[2]=>
string(32) "5f4dcc3b5aa765d61d8327deb882cf99"
["USER_EMAIL"]=>
string(0) ""
[3]=>
string(0) ""
["USER_LEGION"]=>
string(1) "1"
[4]=>
string(1) "1"
["USER_ENERGY"]=>
string(4) "2812"
[5]=>
string(4) "2812"
["USER_MAX_ENERGY"]=>
string(4) "2812"
[6]=>
string(4) "2812"
["USER_SHIELD"]=>
string(2) "20"
[7]=>
string(2) "20"
["USER_MAX_SHIELD"]=>
string(2) "20"
[8]=>
string(2) "20"
["USER_HULL"]=>
string(2) "60"
[9]=>
string(2) "60"
["USER_MAX_HULL"]=>
string(2) "60"
[10]=>
string(2) "60"
["USER_CREDITS"]=>
string(19) "9223372036854775807"