Php 无法使用数组元素

Php 无法使用数组元素,php,sql,Php,Sql,下面的代码应该获得纬度和经度,并生成一个人居住的完整地址(街道、城市、国家)。所有这些都是成功的,但当我对地址使用explode函数并将数据放入数组元素时。我无法从每个元素中获取数据。注意:我在每个数组元素上使用了echo,它们可以很好地输出到屏幕上。 这就是我得到的错误:注意:第36行C:\wamp\www\bloodonation\geosendmail.php中未定义的偏移量:1 注意:第37行的C:\wamp\www\bloodonation\geosendmail.php中未定义的偏移

下面的代码应该获得纬度和经度,并生成一个人居住的完整地址(街道、城市、国家)。所有这些都是成功的,但当我对地址使用explode函数并将数据放入数组元素时。我无法从每个元素中获取数据。注意:我在每个数组元素上使用了echo,它们可以很好地输出到屏幕上。 这就是我得到的错误:注意:第36行C:\wamp\www\bloodonation\geosendmail.php中未定义的偏移量:1 注意:第37行的C:\wamp\www\bloodonation\geosendmail.php中未定义的偏移量:2。第36行和第37行是爆炸功能之后的行。我希望在sql查询中使用$city的值。请帮帮我。我错过了什么。这是echo的数据:哈巴尔贝鲁特黎巴嫩。我希望在sql查询中使用贝鲁特的城市

    $address= getaddress($latitude,$longitude);
$multiple= explode(',',$address);
$parseaddress = $multiple[0]; // address   
$city = $multiple[1]; // city
$country = $multiple[2]; // country

// getting a persons email
//$to;

//Take contents of the search box
//mail function parameters, send two sets of messages depending on blood/organ donation
  //create a temp file in bloodonation and take the name from there,then delete the temp file

    $firstname=$_SESSION["firstname"];
    $fathername=$_SESSION["fathername"];
    $lastname=$_SESSION["lastname"];
    $query ="SELECT email,bloodoner,organdoner,bloodtype,bodytype
        FROM personprofile
        WHERE   firstname= '$firstname' AND lastname= '$lastname' AND fathername= '$fathername'";
        $fetchemail=  mysqli_query($link,$query);
        $process=mysqli_fetch_assoc($fetchemail);

        $pbloodtype="SELECT personprofile.bloodtype,personprofile.firstname,personprofile.lastname,personprofile.fathername,hospital.hospitalname
        FROM personprofile,hospital,areaname 
        WHERE areaname.id= hospital.area AND personprofile.hospitaladmission= hospital.id AND areaname.area='$city'";  

此处必须添加“您的代码易受SQL注入攻击”注释。请不要将值直接插入查询中。改为使用参数。如果使用echo“”,输出是什么;模具(打印($multiple));就在爆炸之后?听起来好像
$multiple
不包含您认为它所包含的内容。以@GlenElkins为例,看看它真正包含了什么。