2013-11-27 61 views
1

API層(move_shopping_list.php):的API層返回JSON編碼,我發現了以下錯誤

if (!isset($_GET['i_sign_in_token'])){ 
    die(json_encode('Must pass in the i_sign_in_token into the url')); 
} 

if (!isset($_GET['itm_cd'])){ 
    die(json_encode('Must pass in itm_cd into the URL')); 
} 

if (!isset($_GET['list_id_old']) || !isset($_GET['list_id_new'])){ 
    die(json_encode('Must pass in the list_id_old or new value into the URL')); 
} 


$list = new ShoppingListItem($_GET['i_sign_in_token'], $_GET['itm_cd'], $_GET['list_id_old'], $_GET['list_id_new']); 
$moveItems = $item->move_between_lists($token, $_GET['itm_cd'], $_GET['list_id_old'], $_GET['list_id_new']); 

echo json_encode($moveItems); 

下面是我列出的方法之間的舉動我ShoppingListItem類內:

public function move_between_lists($shopper, $new_list_id) { 
    global $pd, $db; 

    // todo: don't forget to update $this->ShoppingList 
    $vars = array(); 
    $vars[] = array('i_sign_in_token', $shopper); 
    $vars[] = array('itm_cd', $this->ITM_CD); 
    $vars[] = array('list_id_old', $this->SHOPPING_LIST_ID); 
    $vars[] = array('list_id_new', $new_list_id); 

    $rows = $db->get_function_as_proc('custom.japi_shopping_list.Move_Bewteen_Lists(:i_sign_in_token, :itm_cd, :list_id_old, :list_id_new)', $vars); 

    if ($rows == 'Y') { 
     // Must have worked or it would have returned. 
     $this->SHOPPING_LIST_ID = $new_list_id; 

     return true; 
    } else { 
     return false; 
    } 


} 

我不斷收到這些錯誤,我不知道爲什麼..任何幫助將不勝感激。

Notice: Undefined index: i_sign_in_token in /var/www/api/move_shopping_list.php on line 3 Notice: Undefined index: itm_cd in /var/www/api/move_shopping_list.php on line 7 Notice: Undefined index: list_id_old in /var/www/api/move_shopping_list.php on line 11 Notice: Undefined index: list_id_new in /var/www/api/move_shopping_list.php on line 15 Notice: Undefined index: i_sign_in_token in /var/www/api/move_shopping_list.php on line 19 Notice: Undefined index: itm_cd in /var/www/api/move_shopping_list.php on line 19 Notice: Undefined index: list_id_old in /var/www/api/move_shopping_list.php on line 19 Notice: Undefined index: list_id_new in /var/www/api/move_shopping_list.php on line 19 Notice: Undefined variable: item in /var/www/api/move_shopping_list.php on line 20 Fatal error: Call to a member function move_between_lists() on a non-object in /var/www/api/move_shopping_list.php on line 20

回答

2

如果在$ _GET數組鍵不,你明確地檢查這種不存在的鍵是否也不是一個空字符串。邏輯錯誤,您不得使用&&(和),但||(或)。

+0

感謝您的幫助,使用或解決了我的問題。 =]當時間到期時,我將標記爲正確的答案。 –

+0

我應該如何確定它是舊購物清單還是新購物清單?我將更新我的代碼.. –

+0

現在我要返回這個錯誤'「必須將list_id_old值傳遞到URL中,但我在URL中有list_id_old = 1。 –

相關問題