api图层(move_shopping_list.php):
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类中的lists方法之间移动:
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
答案 0 :(得分:2)
如果未设置$ _GET中的数组键,则显式检查此不存在的键是否也不是空字符串。逻辑错误,您不能使用&&
(和)||
(或)。