my code is supposed to send to the organ donor & blood donor depending on which he is an email with the name of the patient and hospital he is staying at. However if I put 2 people in the hospital with the same attributes as the person doing the donation .Supposed to append $messagebody and $hyperlink to $message It gives me this error - Parse error: syntax error, unexpected '$message' (T_VARIABLE), expecting ';' in C:\wamp\www\bloodonation\geosendmail.php on line 58 Please help me. This is my code
$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