I want to send alerts by email

0

I want to send alerts by email when the user's appointment is 3 days from its due date. but I get this error.

  

Warning: mysqli_error () expects exactly 1 parameter, 0 given in /usr/home/anasdprueba.com/web/envioemail.php

supposedly the query is wrong, thanks in advance

$sql = "select agenda.*, usuario.email from agenda inner join usuario ON agenda.idusuario = usuario.idusuario".
    "where fecha_fin = date_sub(curdate(), interval 3 day)";      

    $rpt = mysqli_query($cn,$sql)or die(mysqli_error());
    $asunto = 'Hola Usuario'; 
    $cuerpo = ' 
    <html> 
    <head> 
       <title>Bienvenido Usuario</title> 
    </head> 
    <body> 

    <p> 
    <b>Buen dia estimado usuario 
    </b>. 
    </p> 
    </body> 
    </html> '; 
    $headers = 'MIME-Version: 1.0\r\n'; 
    $headers .= 'Content-type: text/html; charset=iso-8859-1\r\n';

    while ($des = mysqli_fetch_array($rpt)) {
        $destinatario = $des['email'];
        mail($destinatario,$asunto,$cuerpo,$headers);
    }   
    
asked by Mario Morales 28.04.2017 в 23:45
source

2 answers

0

How about this:

  

All in one line

$sql = "SELECT agenda.*, usuario.email FROM agenda INNER JOIN usuario ON agenda.idusuario = usuario.idusuario WHERE fecha_fin = DATE_SUB(CURDATE(), INTERVAL -3 DAY)";
    
answered by 29.04.2017 / 00:03
source
0

For this it would be correct to use the following SQL query:

SELECT * FROM ventas WHERE prom_entrega >= curdate() + interval + 4 DAY;

According to the needs on dates it is adapted changing the interval to 7, 15, or 30 DAY, etc.

The rest of the code is fine.

    
answered by 15.03.2018 в 22:25