第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

數(shù)據(jù)庫查詢返回:檢查參數(shù)是數(shù)組還是對(duì)象

數(shù)據(jù)庫查詢返回:檢查參數(shù)是數(shù)組還是對(duì)象

PHP
瀟湘沐 2021-05-07 17:23:17
當(dāng)嘗試使用php和mysql登錄此應(yīng)用程序時(shí),將Authorization failed顯示該應(yīng)用程序中使用的錯(cuò)誤。閱讀php_error.log時(shí)顯示:[05.05.2019 03:31:51 UTC] PHP注意:未定義的索引:結(jié)果在第43行的/Applications/MAMP/htdocs/iReporter/api.php中[05-May-2019 03:31:51 UTC] PHP警告:count():參數(shù)必須是在第43行的/Applications/MAMP/htdocs/iReporter/api.php中實(shí)現(xiàn)Countable的數(shù)組或?qū)ο蟮卿浌δ?/login APIfunction 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);//Line 43if (count($result['result'])>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);//editvar_dump($result);} else {    // no matching username/password was found in the login table    errorJson('Authorization failed');}}該應(yīng)用程序用于讓用戶無縫登錄,但突然停止工作,而無需對(duì)代碼進(jìn)行任何更改。即使未更改的備份文件也收到相同的錯(cuò)誤。如何更改代碼以允許用戶成功登錄?更新:index.php。應(yīng)用程序訪問功能的主文件switch ($_POST['command']) {case "login":    login($_POST['username'], $_POST['password']);     break;解決了更改了iOS應(yīng)用程序,以將密碼而不是固定密碼發(fā)布到數(shù)據(jù)庫,因?yàn)樗趧?chuàng)建錯(cuò)誤。
查看完整描述

2 回答

?
料青山看我應(yīng)如是

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ò)誤。


查看完整回答
反對(duì) 回復(fù) 2021-05-28
?
紅顏莎娜

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');

}


}


查看完整回答
反對(duì) 回復(fù) 2021-05-28
  • 2 回答
  • 0 關(guān)注
  • 164 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)