We help IT Professionals succeed at work.

MYSQL PHP, Problem Query

NeoAshura
NeoAshura asked
on
Medium Priority
271 Views
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?

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

Comment
Watch Question

CERTIFIED EXPERT
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION

Author

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
CERTIFIED EXPERT

Commented:
might be that will exceeds the lenght of message of smtp thats why it is giving error

Author

Commented:
Is there a way to change this in the settings? ill reward you the points thanks
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.