Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 263
  • Last Modified:

MYSQL PHP, Problem Query

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?

thanks


<?php
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");
 $result4=mysql_query($sql);
if($result4) {
	$count=mysql_num_rows($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 = "phil@tlk.co";
	 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: admin@tlk.co";
$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
if($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

0
NeoAshura
Asked:
NeoAshura
  • 2
  • 2
1 Solution
 
Pratima PharandeCommented:
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 ";
0
 
NeoAshuraAuthor Commented:
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-5.3.6.0\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.

Thanks
0
 
Pratima PharandeCommented:
might be that will exceeds the lenght of message of smtp thats why it is giving error
0
 
NeoAshuraAuthor Commented:
Is there a way to change this in the settings? ill reward you the points thanks
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now