2 回答

TA貢獻(xiàn)1772條經(jīng)驗(yàn) 獲得超8個(gè)贊
基于該錯(cuò)誤,您沒有result
在$result
變量中獲取該值。要檢查這一點(diǎn),您可以使用:
if (isset($result['result']) && count($result['result']) > 0)
首先檢查該值是否已設(shè)置。
您還需要調(diào)查為什么無法從數(shù)據(jù)庫中獲得預(yù)期的結(jié)果。為此,您將需要查看$result
變量中返回的內(nèi)容,并查找數(shù)據(jù)庫查詢可能返回的任何錯(cuò)誤。

TA貢獻(xiàn)1842條經(jīng)驗(yàn) 獲得超13個(gè)贊
function login($user, $pass) {
// try to match a row in the "login" table for the given username and password
$result = query("SELECT IdUser, username FROM login WHERE username='%s' AND pass='%s' limit 1", $user, $pass);
$rows=$result->num_rows;
//Line 43
if ($rows>0) {
// a row was found in the database for username/pass combination
// save a simple flag in the user session, so the server remembers that the user is authorized
$_SESSION['IdUser'] = $result['result'][0]['IdUser'];
// print out the JSON of the user data to the iPhone app; it looks like this:
// {IdUser:1, username: "Name"}
print json_encode($result);
} else {
// no matching username/password was found in the login table
errorJson('Authorization failed');
}
}
- 2 回答
- 0 關(guān)注
- 164 瀏覽
添加回答
舉報(bào)