我的代码应该发送给器官捐赠者&献血者取决于他是一个电子邮件,上面写着他所住的病人和医院的名字。但是,如果我把2个人放在医院,其属性与捐赠者相同。请提供$ messagebody和$超链接到$ message它给了我这个错误 - 解析错误:语法错误,意外'$ message'(T_VARIABLE ),期待';'在第58行的C:\ wamp \ www \ bloodonation \ geosendmail.php中 请帮我。这是我的代码
$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'";
$fetchbloodtype= mysqli_query($link,$pbloodtype);
$processblood=mysqli_fetch_assoc($fetchbloodtype);
// Send the blood donation email if person is blood donner
if($process['bloodoner']=="Yes" && $processblood['bloodtype']==$process['bloodtype']){ //with same bloodtype
$to=$process['email'];
$header= "Blood is urgently needed";
$phquery="SELECT personprofile.firstname,personprofile.lastname,personprofile.fathername,hospital.hospitalname,hospital.geolocation
FROM personprofile,hospital,areaname
WHERE areaname.id= hospital.area AND personprofile.hospitaladmission= hospital.id AND areaname.area='$city'";
$fetchospitalperson= mysqli_query($link,$phquery);
$processtable=mysqli_fetch_assoc($fetchospitalperson);
do{
$messagebody= "Patient Name: ".$processtable['firstname']." ".$processtable['fathername']." ".$processtable['lastname']." "."Hospital Name:";
//$hyperlink= new DOMDocument();
//$hyperlink->loadHTML("<html><body><a href='<".$processtable['geolocation']."'>" .$processtable['hospitalname']."</a></body></html>");
$hyperlink= "<html><body><a href='<".$processtable['geolocation']."'>".$processtable['hospitalname']."</a></body></html>";
//Name of the person that needs the blood transfusion along with hospital he is staying at,hyperlinked to its location
}while($processtable=mysqli_fetch_assoc($fetchospitalperson))
$message= "Dear"." ".$firstname." ".$lastname.",".PHP_EOL .$messagebody.$hyperlink;
if(isset($sendtoperson)){
if(mail($to,$header,$message)){
echo "Sent";
}
else{ echo "Not sent";}
}
}//end of if person was blooddoner
// Send Organ donation email if person is organ donner
$porgandonation="SELECT personprofile.bloodtype,personprofile.bodytype,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'";
$fetchorgan= mysqli_query($link,$porgandonation);
$processorgan=mysqli_fetch_assoc($fetchorgan);
if($process['organdoner']=="Yes" && $processorgan['bloodtype']== $process['bloodtype'] && $processorgan['bodytype']== $process['bodytype'] ){ //with same bloodtype,bodytype,intensivecare
$to=$process['email'];
$header= "Organ is urgently needed";
$phquery="SELECT personprofile.firstname,personprofile.lastname,personprofile.fathername,hospital.hospitalname,hospital.geolocation
FROM personprofile,hospital,areaname
WHERE areaname.id= hospital.area AND personprofile.hospitaladmission= hospital.id AND areaname.area='$city' AND personprofile.admissionreason= 5";
$fetchospitalperson= mysqli_query($link,$phquery);
$processtable=mysqli_fetch_assoc($fetchospitalperson);
do{
$messagebody= "Patient Name: ".$processtable['firstname']." ".$processtable['fathername']." ".$processtable['lastname']." "."Hospital Name:";
//$hyperlink= new DOMDocument();
//$hyperlink->loadHTML("<html><body><a href='<".$processtable['geolocation']."'>" .$processtable['hospitalname']."</a></body></html>");
$hyperlink= "<html><body><a href='<".$processtable['geolocation']."'>".$processtable['hospitalname']."</a></body></html>";
//Name of the person that needs the blood transfusion along with hospital he is staying at,hyperlinked to its location
}while($processtable=mysqli_fetch_assoc($fetchospitalperson))
$message= "Dear"." ".$firstname." ".$lastname.",".PHP_EOL .$messagebody.$hyperlink.PHP_EOL;
if(isset($sendtoperson)){
if(mail($to,$header,$message)){
echo "Sent";
}
else{ echo "Not sent";}
}
} //end of if person was organdonor
答案 0 :(得分:0)
首先,这里的查询不一定会返回一个唯一的条目(如果这是你的意图),因为人们可以共享一个名字,一个姓氏和一个父亲的名字!您可以为唯一条目使用唯一ID
$query ="SELECT email,bloodoner,organdoner,bloodtype,bodytype
FROM personprofile
WHERE firstname= '$firstname' AND lastname= '$lastname' AND fathername= '$fathername'";
另外,
您使用mysqli_fetch_assoc
的方式意味着如果有多行,它仍然只会返回一行。你可以用这种方式构建它:
while($process=mysqli_fetch_assoc($fetchemail)){
----
}
最后,您的<:p>上缺少;
do {
---------
} while($processtable=mysqli_fetch_assoc($fetchospitalperson))
它应该是:
do {
---------
} while($processtable=mysqli_fetch_assoc($fetchospitalperson));