Jump to content

bryan11

New Members
  • Posts

    4
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

bryan11's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Anyone?  You can't redirect stderr and stdout to a file in PHP? I see some extensive error handling code in the PHP manual but can't find much on redirecting output within PHP.
  2. For several scripts run by cron on a linux/mysql system, I'd like to log all stdout and stderr output to a file. I'm currently using this code to manually write to a log file: $scriptName = "checkStores"; # For checkStores.php $logPath = "/usr/local/company/bin/logs/"; $logPathAndFile = $logPath . $scriptName . ".log"; $logStart = "\n\n----" . date("Y-m-d H:i:s") . "----\nLog entry for " . $scriptName . ".php\n"; if (!$log = fopen($logPathAndFile,"a")) { echo "Cannot open log file [$logFile]\n"; } if (!fwrite($log, $logStart)) { echo "Cannot write to log file [$logFile]\n"; } This works, but all log entries are manual and stderr output goes to the system log. Is there a way to redirect all stdout and stderr to a log file? Here's perl code I've recently used to log everything (stdout and stderr) to a file. An equivalent function in php is what I'm trying to build. sub createLog { my $logFile = shift; open ( STDERR, ">>$logFile" ); open ( STDOUT, ">>$logFile" ); open LOG, ">>$logFile" || die "$0: Can't open log file!"; select( LOG ); $| = 1; # Turn on buffer autoflush for log output print "$0: Starting script ...\n"; select( STDOUT ); } I know that one can redirect I/O from the shell, but I'd prefer to so do this within each php script.
  3. I've been searching records using ranges of dates with this kind of select statement: select * from Orders where Orders.BillName="Village Pantry" and Orders.ShipDate >= '2006-07-25'; Orders.ShipDate is a datetime field. Now I need to select rows from an exact date, but this doesn't yield any results though many rows exist with this date: select * from Orders where Orders.BillName="Fred's" and Orders.ShipDate = '2006-07-25'; I tried several variations on this and the results got weird. For example, using the following query I get dates from 7/24/06 to 7/25/06: select * from Orders where Orders.BillName="Fred's" and Orders.ShipDate < '2006-07-26' and Orders.ShipDate > '2006-07-24' and Orders.QuickBooks != '' order by Orders.ShipDate; How may I select records only for '2006-07-25' ?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.