[PHP] Re: counting with dates (help!)

2002-01-21 Thread Ken Gregg

Another macro language I used had a newdate function. Pass it a data and an
offset in number of days and it would return the new date. I duplicated it
in php here:

function newdate( $strdate, $ndays)
{
# strtotime doesn't like dashes
  $strdate = str_replace("-","/",$strdate);
  $temp = strtotime($strdate);
  $n = $ndays * 24 * 60 * 60;
  $n2 = $temp + $n;
  return( date("Y-m-d", $n2 ));
#  return(date("m/d/Y", $n2 ));
}


Ken Gregg
Enhanced Data Systems, Inc.
http://www.rwre.com for the best in Southwest Oregon Real Estate


Sander Peters wrote:

> Hello,
>
> This is my problem:
>
> $today = date("Ymd", mktime(0,0,0, date(m),date(d),date(Y)));
> $last_week = date("Ymd", mktime(0,0,0, date(m),date(d)-7,date(Y)));
> echo ($today - $last_week);
> The result is a number like 8876 (20020107-20011231 = 8876)
> But in date thinking it should be 7!
>
> How can I let php count in real days/month/years in stead of numbers?
>
> Maybe this is a silly question, but anyone who has the answer would help
> me very much!
>
> Thanks in advance!
>
> --
> Met vriendelijke groet / With Greetings,
>
> Sander Peters
>
>site: http://www.visionnet.nl/
>   email: mailto:[EMAIL PROTECTED]
> webmail: mailto:[EMAIL PROTECTED]



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]


[PHP] open php as stream

2002-01-21 Thread Ken Gregg

This is a tough one to explain but here goes. Running php as cgi on
apache.

I am converting from FirstBase (cgi macro processor) to php and I need
to process a php script from Firstbase running as a cgi program.

The problem is php ignores the command line (-f and script parameters)
passed in popen and tries to process my firstbase script instead.

fb is very close to php so here is my FirstBase script:

{
 chdir( path_dir );

 fh = popen( "/usr/local/bin/php -f wzdownload.php", "r");

 if (fh < 0)
 {
print( "failed to open stream" );
  exit();
 }

  while (fgets(buf, 4096, fh) > 0)
 {
  print( buf );
  print( "" );
 }

 pclose( fh )

}

Any ideas as to how to work around this?

Thanks in advance

Ken Gregg
Enhanced Data Systems, Inc.
http://www.rwre.com for the best in Southwest Oregon Real Estate




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]


[PHP] Re: foreach array into mail isn´t working

2002-01-21 Thread Ken Gregg

Blank lines are important to the parsing of mail messages. File does not strip 
newlines. Try your code and strip the newlines off the email addresses. If you still 
have problems try it and drop the newlines
from the subject.

Ken Gregg
Enhanced Data Systems, Inc.
http://www.rwre.com for the best in Southwest Oregon Real Estate


"Josepablo PéRez" wrote:

> Hello people,
>
> I got this script:
>
>  $maildb = file("mailaddr.txt");
>
> foreach ($maildb as $address)
> { mail($address, "THis is the subject\n", "This is the message\n", "From: 
>[EMAIL PROTECTED]\n"); }
> ?>
>
> The mailaddr.txt looks like:
>
> [EMAIL PROTECTED]
> [EMAIL PROTECTED]
> [EMAIL PROTECTED]
>
> However the script does send mails BUT they look like this:
>
> From Nobody <[EMAIL PROTECTED]>
> To [EMAIL PROTECTED]
> Subject [No Subject]
>
> **From here down is the message body***
>
> Subject THis is the subject
> From: [EMAIL PROTECTED]
>
> This is the message
>
> Anybody have an idea why?? I tried it on 2 servers running PHP4 doesnt work, however 
>i also tried using the mail(...) i used up there but alone and that does work.. so 
>the array is screwing something up..
>
> Josepablo Pérez
>



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]


[PHP] Re: apache not handling 404 errors for .php pages

2001-07-14 Thread Ken Gregg

I get this too. I think it is because I'm running cgi php. Think it is a
500 error.

Easiest fix would to also create a custom 500 error handler.

Ken Gregg
Enhanced Data Systems, Inc.
http://www.rwre.com for the best in Southwest Oregon Real Estate


Scott wrote:

> I have custom 404 error handling setup on my linux apache
> box, however, there's a problem with files that have a PHP
> extension.  it seems that apache itself does not check for the
> existence of the requested .php file and fires up PHP no matter
> what.  if PHP does not find the requested file, it'll bail out
> with that dorky looking "Internal Server Error" *NOT* the
> custom error handler that apache uses for non-php files
>
> example: "notexists.html" and "notexists.php" both do not exist
>
> http://server.com/notexists.html
> will show me the custom 404 page
>
> http://server.com/notexists.php
> will show me the "Internal Server Error", becuase apache fired
> up PHP and passed in "notexists.php" without checking for the
> existence of "notexists.php" first.
>
> A possible solution that comes to mind is to auto_prepend
> a script that will check for the existance of the file
> that PHP is attempting to execute, and die gracefully if
> it does not exist on the server but that would be a bad
> kludge hack (if it even works at all)
>
> anyone have a more elegant solution?



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]