I´m trying to send email to all students from database base but its giving an error.
This is my php code,its giving an error:
(Call to a member function fetch_assoc() on boolean in )on line number 15,
Can any one solve this?
<?php
$connection= new mysqli("localhost", "id1004807_m_muntazir313", "hater007", "sms");
if($connection){ echo "connected";} else { echo "Sorry";}
ini_set('SMTP','myserver');
ini_set('smtp_port',25);
if(isset($_POST["submit"])){
$name=$_POST["name"];
$email=$_POST["email"];
$subject=$_POST["subj"];
$comment=$_POST["comments"];
$sql="SELECT email_name FROM email";
$RS = $connection->query($sql);
while($rw = $RS->fetch_assoc()){
echo $rw["email_name"];
$to= $rw["email_name"];
$headers="From: $name<$email>";
$messege="Name:$name \n\nEmail:$email \n\n Subject:$subject\n\nMessege:$comment";
if(mail($to,$subject,$messege,$headers)){
echo"Email sent";
}else{
echo "Please try again";
}
}}
?>