dongtiannai0654 2015-09-23 08:25
浏览 26

脚本向php中的注册用户发送自动生日愿望时出错

I have written the script of sending automatic e-mail for a given date. I have already set up the cron job to execute this once a day for a given time. But it is not working. Can anyone show me the error here. I'm really new to this. What I'm really supposed to do is to send an automatic email to a user on their birthday

   <?php
    $host="mysql117.000webhost.com/";//hostname
    $username="abc";//mysql_username
    $password="123";//mysql_password
    $dbname="abc";//Database name
    $tbl_name="customer_info";//table name

    $date = date("2005-09-23"); //here my date format in my DB is 2010-09-30
    $link = mysqli_connect('$host','$username','$password','$dbname');
    if($link && mysqli_select_db('$dbname', $link))
    {
  $grabBday = "SELECT b_day,DATE_FORMAT(b_day,'2015-%m-%d') FROM customer_info where b_day = '2002-09-24'";
        //here it will take the name of the person whose bday is on a particular date,I just hard coded this date to check  if this is working
        if($rs = mysqli_query($link, $grabBday))
        {
            while(mysqli_fetch_array($rs))
            {
                mail('abc92@yahoo.com', 'HAPPY BIRTHDAY', 'Many Happy Returns of the day');
            }
        }
    }  ?>
  • 写回答

1条回答 默认 最新

  • douboshan1466 2015-09-23 09:05
    关注

    I am seeing logical difference as you are searching where b_day=$date where $date='2015-09-23' but dob can be '2002-09-23' or '1997-09-23' etc. so you will not get desired output, so you can change your query as per below if everything other than it is fine.

    SELECT * FROM 
    tbl_name 
    WHERE CONCAT(YEAR(CURDATE()),DATE_FORMAT(b_day,'-%m-%d')) = $date
    
    评论

报告相同问题?

悬赏问题

  • ¥15 请提供一个符合要求的网页链接。
  • ¥20 用HslCommunication 连接欧姆龙 plc有时会连接失败。报异常为“未知错误”
  • ¥15 网络设备配置与管理这个该怎么弄
  • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码