affordit Posted February 18, 2008 Share Posted February 18, 2008 Can someone tell me what I did wrong here $query = "select * from test WHERE end_date = 'date('Y-m-d', strtotime('+ 5 days'))'"; Link to comment https://forums.phpfreaks.com/topic/91701-help/ Share on other sites More sharing options...
GingerRobot Posted February 18, 2008 Share Posted February 18, 2008 You've tried to use the php date() function in your string. You cannot do that. You must concatenate(join) the returned value of the function with the rest of the string: <?php $query = "select * from test WHERE end_date = '".date('Y-m-d', strtotime('+ 5 days'))."'"; ?> Alternatively, see the the mysql date and time functions Link to comment https://forums.phpfreaks.com/topic/91701-help/#findComment-469640 Share on other sites More sharing options...
kenrbnsn Posted February 18, 2008 Share Posted February 18, 2008 The function will not be run that way, try <?php $query = "select * from test WHERE end_date = '" . date('Y-m-d', strtotime('+ 5 days')) . "'"; ?> Ken Link to comment https://forums.phpfreaks.com/topic/91701-help/#findComment-469642 Share on other sites More sharing options...
affordit Posted February 18, 2008 Author Share Posted February 18, 2008 Still just get a blank page Link to comment https://forums.phpfreaks.com/topic/91701-help/#findComment-469652 Share on other sites More sharing options...
uniflare Posted February 18, 2008 Share Posted February 18, 2008 post your script, may not be the query Link to comment https://forums.phpfreaks.com/topic/91701-help/#findComment-469653 Share on other sites More sharing options...
affordit Posted February 18, 2008 Author Share Posted February 18, 2008 <?php include("sharons_dbinfo.inc.php"); mysql_connect(mysql,$name,$password); @mysql_select_db($database) or die( "Unable to select database"); // // CHANGE QUERY TO GRAB THE ID // $query = "select * from test WHERE end_date = '" . date('Y-m-d', strtotime('+ 5 days')) . "'"; $result=mysql_query($query) or die (mysql_error()); $num=mysql_numrows($result); mysql_close(); $i=0; while ($i < $num) { $company=mysql_result($result,$i,"company"); $name=mysql_result($result,$i,"name"); $address=mysql_result($result,$i,"address"); $city=mysql_result($result,$i,"city"); $state=mysql_result($result,$i,"state"); $zip=mysql_result($result,$i,"zip"); $phone=mysql_result($result,$i,"phone"); $acct_num=mysql_result($result,$i,"acct_num"); $email=mysql_result($result,$i,"email"); $start_date=mysql_result($result,$i,"start_date"); $end_date=mysql_result($result,$i,"end_date"); $remind_date=mysql_result($result,$i,"remind"); $lost_password=mysql_result($result,$i,"lost_password"); $lost_password_answer=mysql_result($result,$i,"lost_password_answer"); $to = "$email"; $subject = "Your Subscription is about to expire"; $message="This mail was sent to you because your subscrption with Affordable Everything will expire on $end_date.\nYou can login to your account and use the link at the top of the page to renew your registration. If you let your subscription lapse, Your information and ads you have placed will be deleted and you will have to reregister and enter them all again."; $headers = "From: [email protected]"; $sent = mail($to, $subject, $message, $headers) ; if($sent) {print "Your mail was sent successfully"; } else {print "We encountered an error sending your mail"; } ++$i; } ?> Link to comment https://forums.phpfreaks.com/topic/91701-help/#findComment-469655 Share on other sites More sharing options...
uniflare Posted February 18, 2008 Share Posted February 18, 2008 try this tell us what it says: <?php include("sharons_dbinfo.inc.php"); mysql_connect(mysql,$name,$password) or die(mysql_error()); @mysql_select_db($database) or die( "Unable to select database"); // // CHANGE QUERY TO GRAB THE ID // $query = "select * from test WHERE end_date = '" . date('Y-m-d', strtotime('+ 5 days')) . "'"; $result=mysql_query($query) or die (mysql_error()); $num=mysql_numrows($result); print_r(mysql_fetch_array($result)); mysql_close(); $i=0; while ($i < $num) { $company=mysql_result($result,$i,"company"); $name=mysql_result($result,$i,"name"); $address=mysql_result($result,$i,"address"); $city=mysql_result($result,$i,"city"); $state=mysql_result($result,$i,"state"); $zip=mysql_result($result,$i,"zip"); $phone=mysql_result($result,$i,"phone"); $acct_num=mysql_result($result,$i,"acct_num"); $email=mysql_result($result,$i,"email"); $start_date=mysql_result($result,$i,"start_date"); $end_date=mysql_result($result,$i,"end_date"); $remind_date=mysql_result($result,$i,"remind"); $lost_password=mysql_result($result,$i,"lost_password"); $lost_password_answer=mysql_result($result,$i,"lost_password_answer"); $to = "$email"; $subject = "Your Subscription is about to expire"; $message="This mail was sent to you because your subscrption with Affordable Everything will expire on $end_date.\nYou can login to your account and use the link at the top of the page to renew your registration. If you let your subscription lapse, Your information and ads you have placed will be deleted and you will have to reregister and enter them all again."; $headers = "From: [email protected]"; $sent = mail($to, $subject, $message, $headers) ; if($sent) {print "Your mail was sent successfully"; } else {print "We encountered an error sending your mail"; } ++$i; } ?> Link to comment https://forums.phpfreaks.com/topic/91701-help/#findComment-469657 Share on other sites More sharing options...
affordit Posted February 18, 2008 Author Share Posted February 18, 2008 Just a blank page Link to comment https://forums.phpfreaks.com/topic/91701-help/#findComment-469672 Share on other sites More sharing options...
uniflare Posted February 18, 2008 Share Posted February 18, 2008 try this tell us what it says (its either query or display_errors() is set off) <?php include("sharons_dbinfo.inc.php"); mysql_connect(mysql,$name,$password) or die(mysql_error()); @mysql_select_db($database) or die( "Unable to select database"); // // CHANGE QUERY TO GRAB THE ID // $query = "select * from test"; $result=mysql_query($query) or die (mysql_error()); $num=mysql_numrows($result); print_r(mysql_fetch_array($result)); exit(); // debug lines mysql_close(); $i=0; while ($i < $num) { $company=mysql_result($result,$i,"company"); $name=mysql_result($result,$i,"name"); $address=mysql_result($result,$i,"address"); $city=mysql_result($result,$i,"city"); $state=mysql_result($result,$i,"state"); $zip=mysql_result($result,$i,"zip"); $phone=mysql_result($result,$i,"phone"); $acct_num=mysql_result($result,$i,"acct_num"); $email=mysql_result($result,$i,"email"); $start_date=mysql_result($result,$i,"start_date"); $end_date=mysql_result($result,$i,"end_date"); $remind_date=mysql_result($result,$i,"remind"); $lost_password=mysql_result($result,$i,"lost_password"); $lost_password_answer=mysql_result($result,$i,"lost_password_answer"); $to = "$email"; $subject = "Your Subscription is about to expire"; $message="This mail was sent to you because your subscrption with Affordable Everything will expire on $end_date.\nYou can login to your account and use the link at the top of the page to renew your registration. If you let your subscription lapse, Your information and ads you have placed will be deleted and you will have to reregister and enter them all again."; $headers = "From: [email protected]"; $sent = mail($to, $subject, $message, $headers) ; if($sent) {print "Your mail was sent successfully"; } else {print "We encountered an error sending your mail"; } ++$i; } ?> Link to comment https://forums.phpfreaks.com/topic/91701-help/#findComment-469674 Share on other sites More sharing options...
affordit Posted February 18, 2008 Author Share Posted February 18, 2008 That pulled every record out Link to comment https://forums.phpfreaks.com/topic/91701-help/#findComment-469681 Share on other sites More sharing options...
uniflare Posted February 18, 2008 Share Posted February 18, 2008 your query is definetely the problem, could you give some examples of the date format in your mysql tables? Link to comment https://forums.phpfreaks.com/topic/91701-help/#findComment-469690 Share on other sites More sharing options...
affordit Posted February 18, 2008 Author Share Posted February 18, 2008 The field is set to DATE and the format is 0000-00-00 Link to comment https://forums.phpfreaks.com/topic/91701-help/#findComment-469694 Share on other sites More sharing options...
EchoFool Posted February 18, 2008 Share Posted February 18, 2008 <?php mysql_connect(mysql,$name,$password) or die(mysql_error()); @mysql_select_db($database) or die( "Unable to select database"); // // CHANGE QUERY TO GRAB THE ID // $query = "select * from test"; $result=mysql_query($query) or die (mysql_error()); $num=mysql_num_rows($result); print_r(mysql_fetch_array($result)); exit(); // debug lines mysql_close(); $i=0; while ($i < $num) { $company=mysql_result($result,$i,"company"); $name=mysql_result($result,$i,"name"); $address=mysql_result($result,$i,"address"); $city=mysql_result($result,$i,"city"); $state=mysql_result($result,$i,"state"); $zip=mysql_result($result,$i,"zip"); $phone=mysql_result($result,$i,"phone"); $acct_num=mysql_result($result,$i,"acct_num"); $email=mysql_result($result,$i,"email"); $start_date=mysql_result($result,$i,"start_date"); $end_date=mysql_result($result,$i,"end_date"); $remind_date=mysql_result($result,$i,"remind"); $lost_password=mysql_result($result,$i,"lost_password"); $lost_password_answer=mysql_result($result,$i,"lost_password_answer"); $to = "$email"; $subject = "Your Subscription is about to expire"; $message="This mail was sent to you because your subscrption with Affordable Everything will expire on $end_date.\nYou can login to your account and use the link at the top of the page to renew your registration. If you let your subscription lapse, Your information and ads you have placed will be deleted and you will have to reregister and enter them all again."; $headers = "From: [email protected]"; $sent = mail($to, $subject, $message, $headers) ; if($sent) {print "Your mail was sent successfully"; } else {print "We encountered an error sending your mail"; } ++$i; } ?> Try that... you may want to put Error report ALL on ... just to get a bigger answer of errors. Link to comment https://forums.phpfreaks.com/topic/91701-help/#findComment-469700 Share on other sites More sharing options...
affordit Posted February 18, 2008 Author Share Posted February 18, 2008 The problem is with this line somewhere $query = "select * from test WHERE end_date = '" . date('Y-m-d', strtotime('+ 5 days')) . "'"; Link to comment https://forums.phpfreaks.com/topic/91701-help/#findComment-469712 Share on other sites More sharing options...
uniflare Posted February 18, 2008 Share Posted February 18, 2008 your query is not returning any MATCHES or RESULTS, there are no entries where end_date = 2008-02-23, the code is fine, your query will return rows where the DATE/end_date field equals 5 days in the future... is this what your trying to do? try this and copy and paste the result from the browser source exactly. <?php include("sharons_dbinfo.inc.php"); mysql_connect(mysql,$name,$password) or die(mysql_error()); @mysql_select_db($database) or die( "Unable to select database"); // // CHANGE QUERY TO GRAB THE ID // $query = "select `end_date` from test LIMIT 50"; $result=mysql_query($query) or die (mysql_error()); $num=mysql_numrows($result); print_r(mysql_fetch_array($result)); exit(); mysql_close(); $i=0; while ($i < $num) { $company=mysql_result($result,$i,"company"); $name=mysql_result($result,$i,"name"); $address=mysql_result($result,$i,"address"); $city=mysql_result($result,$i,"city"); $state=mysql_result($result,$i,"state"); $zip=mysql_result($result,$i,"zip"); $phone=mysql_result($result,$i,"phone"); $acct_num=mysql_result($result,$i,"acct_num"); $email=mysql_result($result,$i,"email"); $start_date=mysql_result($result,$i,"start_date"); $end_date=mysql_result($result,$i,"end_date"); $remind_date=mysql_result($result,$i,"remind"); $lost_password=mysql_result($result,$i,"lost_password"); $lost_password_answer=mysql_result($result,$i,"lost_password_answer"); $to = "$email"; $subject = "Your Subscription is about to expire"; $message="This mail was sent to you because your subscrption with Affordable Everything will expire on $end_date.\nYou can login to your account and use the link at the top of the page to renew your registration. If you let your subscription lapse, Your information and ads you have placed will be deleted and you will have to reregister and enter them all again."; $headers = "From: [email protected]"; $sent = mail($to, $subject, $message, $headers) ; if($sent) {print "Your mail was sent successfully"; } else {print "We encountered an error sending your mail"; } ++$i; } ?> Link to comment https://forums.phpfreaks.com/topic/91701-help/#findComment-469724 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.