MYSQL PHP, Problem Query

Posted on 2011-04-28
Last Modified: 2012-05-11
Hi Experts,

I have a problem with my query outputting data.

I have the following code.(attached)

as you can see in the code the d%m%y% is set with dots in the middle of them that is because my format in the database is varchar as 12.12.12 I want to keep this format but also wants it to count 90 days from todays date as my code used to do with 12/12/12 all i have changed is / to . and the data was not outputted correctly. please can you help me?


include 'myphp.php';

$sql = "SELECT customer_name, account_number, mobile_number, end_contract
FROM customer_details WHERE STR_TO_DATE(end_contract, '%d.%m.%Y') BETWEEN CURDATE() AND DATE_ADD(CURDATE(), INTERVAL 60 DAY)
 ORDER BY end_contract ASC ";
$result = mysql_query($sql) or die(mysql_error() . " IN $sql");
if($result4) {
	$my_table="<html><table><tr><td>Customer Name</td><td>Account Number</td><td>Mobile Number</td><td>End contract</td></tr>";
	// add more people to "$to" field if you want to send to more people. 
	 $to = "";
	 echo $to;
  $subject = "Results from query";
  $body = "<table border='1'>";
  $body .="<tr>";
  $body .="<th>Customer Name:</th>";
  $body .="<th>Account Number:</th>";
  $body .="<th>Mobile Number:</th>";
  $body .="<th>End Contract:</th>";
  $body .="</tr>";
 while($row = mysql_fetch_array($result4)){
  $body .="<tr>";
  $body .="<td>" . $row['customer_name'] . "</td>";
  $body .="<td>" . $row['account_number'] . "</td>";
  $body .="<td>" . $row['mobile_number'] . "</td>";
  $body .="<td>" . $row['end_contract'] . "</td>";
  $body .="</tr>";
  $body .="</table>";
  $header = "From:";
$headers = "MIME-Version: 1.0rn"; 
$headers .= "Content-type: text/html; charset=iso-8859-1rn"; 
// send email
$sent = mail($to,$subject,$body,"$header\nContent-Type: text/html; charset=iso-8859-1",$headers);


// if not found 
else {
echo "Not found your email in our database";

// if your email succesfully sent
echo "Your Contract Expiry Dates Have Been Sent To Your Email Address.  <a href='contractend.php'>Back to contract end</a>";
else {
echo " Cannot send Confirmation link to your e-mail address";


Open in new window

Question by:NeoAshura
    LVL 39

    Accepted Solution

    you said you need interval 90 days
    in your query it is 60 day
    will it affect ? if yes make it 90 days

    $sql = "SELECT customer_name, account_number, mobile_number, end_contract
    FROM customer_details WHERE STR_TO_DATE(end_contract, '%d.%m.%Y') BETWEEN CURDATE() AND DATE_ADD(CURDATE(), INTERVAL 90 DAY)
     ORDER BY end_contract ASC ";
    LVL 6

    Author Comment

    ahh yeah stupid mistake. How would i make this into say 365 days? or 500 days?

    Ive tried just changeing 90 day to 365 but it came back with the error

    Warning: mail() [function.mail]: SMTP server response: 420 Internal error: Max line length exceeded. in G:\EasyPHP-\www\sendmail.php on line 38
    Cannot send Confirmation link to your e-mail address

    But when it is set as 90 days this error does not occur.

    LVL 39

    Expert Comment

    by:Pratima Pharande
    might be that will exceeds the lenght of message of smtp thats why it is giving error
    LVL 6

    Author Comment

    Is there a way to change this in the settings? ill reward you the points thanks

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Suggested Solutions

    As a database administrator, you may need to audit your table(s) to determine whether the data types are optimal for your real-world data needs.  This Article is intended to be a resource for such a task. Preface The other day, I was involved …
    Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
    Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
    The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    9 Experts available now in Live!

    Get 1:1 Help Now