0

i want to send mails using php. for that i have to take mails id from database so i am fetching data from tables and then i am using mail functions but when i am going server and run it then it shows nothing blank page appears site is pligg cms base site

    <html>
    <head>
    <title>Sending HTML email using PHP</title>
    </head>
    <body>
    <?php
    $mysql_host = "localhost";
    $mysql_database = "db";
    $mysql_user = "r";
    $mysql_password = "s#1#";
    $con=mysql_connect($mysql_host,$mysql_user,$mysql_password);
    if(!$con)
    {
          echo "can't connect";
         die("failed connect".mysql_error());

    }
     $db_select=mysql_select_db($mysql_database);
    if(!$db_select)
    {
        echo "db not connected";
    die(" failed user".mysql_error());
   }

   $query1 = "SELECT * FROM  pligg_users"
   $subject = "Exclusive Facebook Cover Offer.";
   $message = "hello";
   $message .= "  <a href='www.getlikeseasy.com'>Read more</a>";
   $message = wordwrap($message,70);
   $headers = "MIME-Version: 1.0" . "\r\n";
   $headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
   $results = mysql_query($query1);
   if(!$results) 
    {
    echo "query";
    die(mysql_error());
     }
    while($result_array = mysql_fetch_array($results)) 
     {    
    $c = $result_array['user_email'];
    $retval = mail($c,$subject,$message,$headers);
    if( $retval == true )
    {
        echo .$i." Message sent successfully... to".$c;
        echo "<br>";
    }
    else
    {
        echo .$i." Message could not be sent... to".$c;
        echo "<br>";
    }
    $i++;
}
   echo "email sent";
 ?>
<?php
  mysql_close($con);
 ?> 
 </body>
  </html>
tg910
  • 25
  • 1
  • 9

1 Answers1

2

Blank pages are often the result of syntax errors. I would recommend enabling error reporting so you can be self-sufficient with debugging. I have not worked with PHP for many years now, but I expect this SO post will help: PHP: I get a completely blank page, I don't know how to debug this in PHP

You're missing a semi-colon here:

$query1 = "SELECT * FROM  pligg_users"

I don't know if that will fix all of it but it will definitely help.

Edit:

On the code below you have placed a '.' before echoing a variable on lines 3 and 8, remove those as well.

if( $retval == true )
{
    echo .$i." Message sent successfully... to".$c;
    echo "<br>";
}
else
{
    echo .$i." Message could not be sent... to".$c;
    echo "<br>";
}
Lati.Chris
  • 57
  • 6