Link to home
Start Free TrialLog in
Avatar of Richard Korts
Richard KortsFlag for United States of America

asked on

Strange php behavior

I have the attached php program that sends an email using PHPMailer().

I recognize that the preliminary code looks odd, but ignoring that, this code does precisely what it is supposed to EXCEPT when it is run AFTER 4:00 PM, Pacific Time USA, in which case, it does NOT send the email.

I recognize that GMT is 8 hours ahead of USA Pacific, so I am suspicious it has something to do with that.

That's why I put this in:

date_default_timezone_set('America/Los_Angeles');

Any ideas?
send_email_ls250.php
Avatar of Bernard Savonet
Bernard Savonet
Flag of France image

There seems to be a typo which causes a  bug at /..summ which should probably be ../summ

But this is probably NOT the siurce of your problem
Avatar of Richard Korts

ASKER

Yes, that is wrong, but the code works at any time except AFTER 4 PM, Pacific.
ASKER CERTIFIED SOLUTION
Avatar of Chris Stanyon
Chris Stanyon
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Ok, I will check that out.

Thanks.
Provide details of what your failure looks like.

This data will come from your MTA logs, so EXIM/Postfix/Sendmail, whatever MTA you're running.

The SMTP status returned for one of these failures will likely provide an instant answer.
Chris,

$letters = range, that will make it much easier.

To al, I will check the rest later today.

Thank you,

Richard
Hey Richard,

Here's the general idea on how to use the range() function.

session_start();

$vid = $_SESSION['vid'];
$letters = array_merge( range( 'm', 'a' ), array( '' ) );
$copiedFiles = array();

foreach( $letters as $letter ):
    $source = "../summsp/{$vid}summary{$letter}.pdf";
    $dest = "thold/" . basename( $source );
    if ( $copied = @copy( $source, $dest ) ) {
        $copiedFiles[] = $source;
    }
endforeach;

$latestFile = count($copiedFiles) ? $copiedFiles[0] : null;

Open in new window

Chris,

I get the idea completely.

One of the issues I have, in GENERAL, as I'm sure you ALL can tell, I go Waaaaaay back to procedural programming, I do not understand a lot of Objective programming. I'd guess I've picked up 15 to 20% of it.

Just FYI, I wrote my first program on a Bendix G-15 in 1961. It was, of course, a vacuum tube machine with ONLY drum memory & only programming in Assembly Language. 58 years ago, a LONG time.

Richard
Hey Richard,

Totally understand. Working in programming is always a constant learning curve, and the easy option is to fall back to what you already know.

All the code we've dicsused here is actually procedural programming. The only part that's actually OOP is the PHPMailer stuff. You've got the mySQLi parts in procedural too, and that's the beauty of it - we can (and often do) mix and match between procedural and OOP.

PHP has grown into a pretty rich language and it contains a huge number of functions. Of cource, the trick is knowing what functions are available to get the job done, and this is where people tend to fall back to known patterns.

But like anything ... practice, practice, practice :)
To all,

This has taken a back seat to other priorities. I still need to fix it, but not till next week at the earliest, maybe later.

Thanks
Avatar of skullnobrains
skullnobrains

pretty sure you miss an "else echo some basic debug information" after the "if ($ls['sub_date'] == date('Y-m-d')) {      "

regarding the ++ and -- and letters (unless this changed for the worst once more with newer OO-fans taking the control of php and trying to make it behave like java ), it is supported to apply such operations to strings : "$x='a' ; $x++ ; echo $x;" is actually expected to output "b" and documented as such. so you are perfectly legit in using "for ($x='m';$x--;$x<='Z' ){ ... }".

if you do not like OO, it is quite trivial to build a simple email with an attachment in php. and given the fact your body text appears to be empty, it is also perfectly legit to send the PDF directly without playing with mime and boundaries as long as you use the proper content-type header.
I'm dropping this for now. Awarding points to stop EE from bugging me.