一段时间以来,我一直在寻找解决这个问题的方法,我发现的大部分内容是那些没有检查 $_GET 变量是否设置的人是有这个错误的人。但是,我确实检查了它们是否已设置但我仍然想出了这个错误。这是我的代码:
$customer_id = $_GET['customer_id'];
$actual_customer_id = $_GET['actual_customer_id'];
if (isset($_GET['customer_id'])&& $_GET['actual_customer_id'])
{
$query = "SELECT rewards_points.points,customers.id AS customerID, customers.email
FROM rewards_points,customers WHERE rewards_points.customer_id= $customers_id AND
$actual_customer_id = rewards_points.actual_customer_id";
}
$query = "SELECT rewards_points.points,customers.id AS customerID, customers.email
FROM rewards_points,customers";
错误是:
Notice: Undefined index: customer_id in /Applications/MAMP/htdocs/insertintotestt.php on line 14
Notice: Undefined index: actual_customer_id in /Applications/MAMP/htdocs/insertintotestt.php on line 15
[{"points":"20","customerID":"1","email":"someEmail@gmail.com
{"points":"20","customerID":"2","email":"otherEmail@gmail.com"},
{"points":"10","customerID":"1","email":"aha238@gmail.com"},
{"points":"10","customerID":"2","email":"spgiegg@gmail.com"},
{"points":"15","customerID":"1","email":"aha238@gmail.com"},
{"points":"15","customerID":"2","email":"spgiegg@gmail.com"},
{"points":"25","customerID":"1","email":"aha238@gmail"},
{"points":"25","customerID":"2","email":"spgiegg@gmail.com"}]