schandhok Posted October 25, 2006 Share Posted October 25, 2006 Hi Guys Here is my php file that i execute through crontab setting<?phpinclude "register_globals.php";$sql_user='chandhs'; // user mysql$sql_password='gnome007'; // password mysql 4 user$blas=curl_init();$db=mysql_connect('localhost',$sql_user,$sql_password);mysql_select_db("blast",$db);$rez=mysql_query("SELECT s_time,s_query_last,s_cdate,u_mail FROM search, users WHERE s_user=u_id");while(list($response_time,$my_query,$cdate,$mail_respons_addr)=mysql_fetch_row($rez)){# $file_mail_respons = fopen('/tmp/.mailrespons.txt', 'w'); $file_mail_respons = fopen('mailrespons.txt', 'w'); $flag=false; if($my_query!=''){ switch($response_time){ case '0': break; case '1':$flag=true; break; case '2': if(date('w')==='1'){ $flag=true; } break; case '3': if(date('d')==='01'){ $flag=true; } break; } } if($flag){ $blas=curl_init();# curl_setopt($blas,CURLOPT_URL,"http://www.ncbi.nlm.nih.gov/blast/Blast.cgi");# curl_setopt($blas,CURLOPT_POSTFIELDS,trim($my_guery_h)); curl_setopt($blas,CURLOPT_URL,"http://www.ncbi.nlm.nih.gov/blast/Blast.cgi"); curl_setopt($blas,CURLOPT_POSTFIELDS,$my_query); curl_setopt($blas,CURLOPT_FILE,$file_mail_respons); curl_exec($blas); curl_close($blas); fclose($file_mail_respons); $file_mail_respons = fopen('mailrespons.txt', 'r');# $file_mail_respons = fopen('/tmp/.mailrespons.txt', 'r'); $mail_respons_text = fread($file_mail_respons,100000); fclose($file_mail_respons);#$temp=$mail_respons_text;$temp_response=str_replace("<form action=\"Blast.cgi\"","<form action=\"http://www.ncbi.nlm.nih.gov/blast/Blast.cgi\"",$mail_respons_text);# echo $mail_respons_addr."<br>".$mail_respons_text."<br>",$my_query,"<br>";# Mail($mail_respons_addr,"",$mail_respons_text); Mail($mail_respons_addr,"",$temp_response);#echo $temp_response; }} mysql_close($db);exit;?>My problem is that in my site when i choose this file to run daily, i get results in my email around 60 in a day same email. Why doesnt it send me just one email instead of sending 60 at a time?My crontab setting for running this file is : * 0 * * * /home/chandhs/blast_site/myblast4cron.phpPls help. ??? Quote Link to comment Share on other sites More sharing options...
Psycho Posted October 25, 2006 Share Posted October 25, 2006 Your Mail function site within a WHILE loop. So every time the the loop is traversed an email will be gererated.The WHILE loop is based upon the records queried from the database. So, you will get one email for every record that is returned from the query. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.