How to put email variables with phpMailer?

-2
$sql = ("SELECT nome, datas FROM tabelas WHERE datediff(now(), data) <= 10 ");
$validade = mysql_query($sql);

while....
(codigo phpmailer)
// corpo da mensagem
$PHPMailer->Body = "<p>Faltam 10 dias ou menos para terminar a data do Documento  ".$Nome."</p>";

I need the message to show me the Name and the date that is less than 10 days old to finish being inserted in the DB.

I tried to test with just the name and it also does not work.

$PHPMailer->Body = "<p>Faltam 10 dias ou menos para terminar a data do Documento ".$Nome."</p>";
    
asked by anonymous 10.02.2014 / 19:02

2 answers

1

Your error is in the query. This is not the way to calculate dates in MySQL / MariaDB. Notice that you are adding an integer, but it does not say what this integer is. The database in this case has a syntax that specifies what type of range is, in this case the INTERVAL

SELECT * FROM tabela 
   WHERE data < (NOW() + INTERVAL 10 DAY) ## data menor que (agora + 10 dias)
         AND data > NOW() ## e maior que agora

Please see this table that talks about date calculation with INTERVAL link

    
10.02.2014 / 22:27
0

The Name and Date you want to show must be in your search.

select nome, data from ...

Your question does not seem to be about phpMailer, but about querying data. Please, better detail the structure of your table and what SGDB.

    
10.02.2014 / 19:31