php-general Digest 19 May 2002 14:18:19 -0000 Issue 1354

Topics (messages 98309 through 98363):

Re: random quote script with flat file? (PHP Vault: Random Quote Script)
        98309 by: Evan Nemerson
        98311 by: Timothy J. Luoma

Re: PHPBB2
        98310 by: Ashley M. Kirchner
        98351 by: Justin French

file upload problem
        98312 by: Rodney Davis
        98332 by: Miguel Cruz
        98343 by: Rodney Davis

Classifieds Program
        98313 by: Andrés de la Varga
        98317 by: David Freeman

xml parsing
        98314 by: Gerard Samuel

Re: Register_Shutdown_Function ??
        98315 by: CC Zona
        98321 by: Jason Caldwell
        98341 by: Jason Caldwell

Read a var from stdin
        98316 by: Rafael Perazzo
        98337 by: Miguel Cruz

Problem with
        98318 by: webmaster.tececo.com
        98319 by: Richard Baskett

Re: date functions
        98320 by: Tom Rogers
        98328 by: Miguel Cruz

Augmenting an old date
        98322 by: Andre Dubuc
        98324 by: SP
        98325 by: Tom Rogers
        98326 by: Tom Rogers
        98330 by: SP
        98355 by: Andre Dubuc

bug in SLEEP() function...
        98323 by: Jason Caldwell

Re: Confused about which function to use with forms/database
        98327 by: Dennis Gearon

regex (preg_replace)
        98329 by: Gerard Samuel
        98335 by: Gerard Samuel

Sessions
        98331 by: Navid Y.
        98334 by: Miguel Cruz

php.net sloooooooowwww
        98333 by: Jason Caldwell
        98336 by: Miguel Cruz
        98338 by: mike
        98339 by: Jason Caldwell
        98340 by: CC Zona

Compressing my web pages?
        98342 by: Jason Caldwell
        98352 by: Jason Wong

Output_Buffering ??
        98344 by: Jason Caldwell
        98345 by: Jason Caldwell

ob_gzhandler? (compression)
        98346 by: Jason Caldwell
        98347 by: Gerard Samuel
        98348 by: Miguel Cruz

How to encode e-mail attachments, work with MIME
        98349 by: Carlos Fernando Scheidecker Antunes
        98357 by: Jason Morehouse
        98358 by: Manuel Lemos
        98359 by: Manuel Lemos

Non cachable php for use as an <img src>
        98350 by: Henry

PFDLib Function Problem
        98353 by: Maurice Kevenaar

refresh (part of) a page?
        98354 by: savaidis
        98360 by: Jason Wong

Help with file read
        98356 by: Josh Edwards
        98361 by: Jason Wong

A new GUI client for mySQL
        98362 by: Ritesh Nadhani

Trouble with recocnizing jpeg files. Some work, some do not
        98363 by: andy

Administrivia:

To subscribe to the digest, e-mail:
        [EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
        [EMAIL PROTECTED]

To post to the list, e-mail:
        [EMAIL PROTECTED]


----------------------------------------------------------------------
--- Begin Message ---
list($usec,$sec)=explode(" ",microtime());
mt_srand($sec * $usec);
$quotes = file("quotes");
echo $quotes[mt_rand(0, (sizeof($quotes)-1))];

Should do the trick nicely.


-Evan


-- 
All religions are founded on the fear of the many and the cleverness of the 
few.

Stendhal

--- End Message ---
--- Begin Message ---
> list($usec,$sec)=explode(" ",microtime());
> mt_srand($sec * $usec);
> $quotes = 
file("quotes");
> echo $quotes[mt_rand(0, (sizeof($quotes)-1))];

Yes!!!  That 
works exactly!  I love PHP! I love this list.... and look forward to the day when I 
can 
contribute something more than fascinating questions ;-)

Thank you!

TjL



--- End Message ---
--- Begin Message ---
r wrote:

> Does anybody have any ideas on how i can make PHPBB's width a bit shorter?

    Use PHPBB2's forums for these kind of questions.

--
H | "Life is the art of drawing without an eraser." - John Gardner
  +--------------------------------------------------------------------
  Ashley M. Kirchner <mailto:[EMAIL PROTECTED]>   .   303.442.6410 x130
  Director of Internet Operations / SysAdmin    .     800.441.3873 x130
  Photo Craft Laboratories, Inc.            .     3550 Arapahoe Ave, #6
  http://www.pcraft.com ..... .  .    .       Boulder, CO 80303, U.S.A.


--- End Message ---
--- Begin Message ---
Clearly the BB is designed to fill a page... it seems to have a minimum
width, given the colums, images, etc etc that you can't really avoid... I'm
not clear on the terms/licensing of the BB, but I'd try a mixture of:

1. editing the <table> code(s).... it looks like the "forums" column can be
shrunk down, which would reduce the overall size.

2. replacing some of the images and larger items with smaller ones

3. reducing the font size

BTW - it's fine at 1024x768, so maybe it's *okay* for a certain % of your
user base.... it wouldn't be for my target market tho.


Justin French



on 19/05/02 10:29 PM, r ([EMAIL PROTECTED]) wrote:

> Hi Guys and Girls,
> I have reciently set up PHPbb2 on our site, its great and no problems with
> the software but....
> I am using frames so that a person can at any time jump out of the forum and
> came right back to the site but....
> because of the frames the forum is pushed a lot to the right...(you have to
> scroll sideways to read everything) I know i hate when that happens if I
> visit a website and i'm pretty sure a lot of other people do too.
> Does anybody have any ideas on how i can make PHPBB's width a bit shorter?
> Its set up here:
> http://jumac.com/forums/
> feel free to poke around and if you want post or write something etc....note
> though that I have not "enabled" a link to this location as yet because of
> the width thing....so this section is not opened/dead/unknown
> 
> I dont really know if this is a PHP question but I presume to make any
> changes I will have to dig into the PHP part right?
> 
> ANY advise or help appreciated,
> Thanks in advance,
> -Ryan.
> 
> /*Work...The sooner you fall behind, the more time you'll have to catch
> up.*/
> 

--- End Message ---
--- Begin Message ---
I am trying to use the move_uploaded_file() function to upload files to
a specific directory. It works fine with small .jpgs .txt etc etc but
won't work with a large .mp3 file.  Is this because it is too large?
What can I do?

Thanks

--- End Message ---
--- Begin Message ---
On Sat, 18 May 2002, Rodney Davis wrote:
> I am trying to use the move_uploaded_file() function to upload files to
> a specific directory. It works fine with small .jpgs .txt etc etc but
> won't work with a large .mp3 file.  Is this because it is too large?
> What can I do?

You can tell us what "won't work" means. Do the police come to your door?

miguel

--- End Message ---
--- Begin Message ---
The purpose of the function is to upload a file.  It fails to upload
despite not generating an error.  I went into the php.ini file and found
that the max file size was defaulted to 2mb.  I increased this and it
fixed the problem.  

-----Original Message-----
From: Miguel Cruz [mailto:[EMAIL PROTECTED]] 
Sent: Saturday, May 18, 2002 7:31 PM
To: Rodney Davis
Cc: [EMAIL PROTECTED]
Subject: Re: [PHP] file upload problem

On Sat, 18 May 2002, Rodney Davis wrote:
> I am trying to use the move_uploaded_file() function to upload files
to
> a specific directory. It works fine with small .jpgs .txt etc etc but
> won't work with a large .mp3 file.  Is this because it is too large?
> What can I do?

You can tell us what "won't work" means. Do the police come to your
door?

miguel

--- End Message ---
--- Begin Message ---
I want to add a Classifieds script to my Website. Any recomendation?

Andrés


--- End Message ---
--- Begin Message ---

 > I want to add a Classifieds script to my Website. Any recomendation?

1.  http://www.google.com/

2.  "classifieds web php mysql" in the search box.

3.  Click the "search" button.

4.  The 3rd link on the resulting list looks good.

5.  http://www.hotscripts.com/PHP/Scripts_and_Programs/Classified_Ads/
(which would be the 3rd link mentioned in step 4).

6.  Pick whichever one of the 36 choices mentioned starting on the above
page.

Simple really, and I've never even thought about looking for a
classifieds script before.

CYA, Dave


--- End Message ---
--- Begin Message ---
I got this example from Beginning PHP 4.  Unfortunately, I cant get to 
wrox's site to see if there were any errata updates for this piece of 
code, but for the life of me, I dont know whats wrong with it.  All its 
displaying is '-'.  If anyone could direct me to where its broken, Ill 
be very grateful..
------------------------------------------------
<?php

if (!($fp = fopen("http://freshmeat.net/backend/fm.rdf";, "r"))) 
die("Cant fetch");

$item_counter = 0;
$in_item_tag = 0;
$fm_current_tag_state = '';
$fm_headline_data = array();

function startElementHandler($parser, $element_name, $element_attribs) {
    global $item_counter, $in_item_tag, $fm_current_tag_state, 
$fm_headline_data;
    if ($element_name == "ITEM") {
        $in_item_tag = 1;
    }

    if ($in_item_tag == 1) {
        $fm_curent_tag_state = $element_name;
    } else {
        $fm_current_tag_state = '';
    }
}

function endElementHandler($parser, $element_name) {
    global $item_counter, $in_item_tag, $fm_current_tag_state, 
$fm_headline_data;
    $fm_current_tag_state = '';
    if ($element_name == "ITEM") {
        $item_counter++;
        $in_item_tag = 0;
    }
}

function characterDataHandler($parser, $data) {
    global $itme_counter, $in_item_tag, $fm_current_tag_state, 
$fm_headline_data;

    if ($fm_current_tag_state == '' || $in_item_tag == 0) return;

    if ($fm_current_tag_state == "TITLE") 
$fm_headline_data[$item_counter]['title'] = $data;

    if ($fm_current_tag_state == "LINK") 
$fm_headline_data[$item_counter]['link'] = $data;

    if ($fm_current_tag_state == "DESCRIPTION") 
$fm_headline_data[$item_counter]['description'] = $data;
}

if (!($xml_parser = xml_parser_create())) die("Parser Problem");

xml_set_element_handler($xml_parser, "startElementHandler", 
"endElementHandler");
xml_set_character_data_handler($xml_parser, "characterDataHandler");

while ($data = fread($fp, 4096)) {
    if (!xml_parse($xml_parser, $data, feof($fp))) {
        break;
    }
}

xml_parser_free($xml_parser);

for($i=0; $i < $item_counter; $i++) {
    printf("<a href=\"%s\">%s</a> - %s<br>\n", 
$fm_headlines_data[$i]['link'],
                                               
$fm_headlines_data[$i]['title'],
                                               
$fm_headlines_data[$i]['description']
                                               );
}

?>

--- End Message ---
--- Begin Message ---
In article <[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] (Jason Caldwell) wrote:

> Here's my code:
> ----------------
> <?
>  set_time_limit(1);
>  function clean_up()
>  {
>   if(connection_status() & TIMEOUT)
>    print("Script timed out.\n");
>  }
> register_shutdown_function("clean_up");
> while(1);
> ?>
> 
> Here's the message I get:  (I should get "Script timed out.")

No, you shouldn't/wouldn't, because--as is noted in the docs 
<http://php.net/register-shutdown-function>--no more output ("print" is 
specifically mentioned as an example) can be sent to the browser at that 
stage.  Try sending youself an email, or logging to a file instead.

-- 
CC
--- End Message ---
--- Begin Message ---
It doesn't matter.  I'm setting the output *not* to the browser, but to the
command shell, where I am running the script from.  If you look at the
errors, you'll see 2 of them, one points to line 7, where the IF() command
is -- the script terminates there...

I've put error_log() and exec() functions in place of the print()
function -- it doesn't make a difference -- the script just won't execute
the function in the register_shutdown_function() --

The following script works great (see below) -- it seems that for some
reason its a TIMEOUT issue (bug).

Running the script below, I will get the output of the print() function --
as stated, from the command line.  I understand that it wouldn't show up in
the browser.

If I replace the "exit;" command with say a "while(1);" where the script
will loop indefinitely, the timeout, set by the set_time_limit(1) will stop
the script, but again -- register_shutdown_function() seems to "want to
work" as the function IS CALLED, but NEVER executed, and instead errors on
the 1st line in the FUNCTION -- always on a TIMEOUT.

Run this script from your command line (ie. C:>php test.php) -- then change
the "set_time_limit(30)" to "set_time_limit(1)", and replace the "exit" with
a "while(1)" -- run the script again, you'll see what I mean.

And, if you still don't believe me, replace the print() in the function with
"error_log('Script Terminated', 3, 'errorlog.txt');" and see if the
"errorlog.txt" file is ever created -- it isn't.

<?
set_time_limit(30);
 function clean_up()
 {
  print("Script Terminated");
 }
register_shutdown_function("clean_up");
 exit;
?>

If anyone can offer any reason why its doing this, please help -- thanks.

Jason




"Cc Zona" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> In article <[EMAIL PROTECTED]>,
>  [EMAIL PROTECTED] (Jason Caldwell) wrote:
>
> > Here's my code:
> > ----------------
> > <?
> >  set_time_limit(1);
> >  function clean_up()
> >  {
> >   if(connection_status() & TIMEOUT)
> >    print("Script timed out.\n");
> >  }
> > register_shutdown_function("clean_up");
> > while(1);
> > ?>
> >
> > Here's the message I get:  (I should get "Script timed out.")
>
> No, you shouldn't/wouldn't, because--as is noted in the docs
> <http://php.net/register-shutdown-function>--no more output ("print" is
> specifically mentioned as an example) can be sent to the browser at that
> stage.  Try sending youself an email, or logging to a file instead.
>
> --
> CC


--- End Message ---
--- Begin Message ---
I just upgraded from 4.1.1 to 4.2.1 -- didn't fix the problem.  I'd be
curious to know if other Windows users are having the same problem.

Thanks.
Jason


--- End Message ---
--- Begin Message ---
Is there any way to ask the user to type the value of
a variable from stdin ? (like read in Pascal, or scanf
in C). I'm using PHP from command line. 

Thanks 

Rafael Perazzo

__________________________________________________
Do You Yahoo!?
LAUNCH - Your Yahoo! Music Experience
http://launch.yahoo.com
--- End Message ---
--- Begin Message ---
On Sat, 18 May 2002, Rafael Perazzo wrote:
> Is there any way to ask the user to type the value of
> a variable from stdin ? (like read in Pascal, or scanf
> in C). I'm using PHP from command line. 

  <?

  $f = fopen('php://stdin', 'r'); // this line answers your question
  while ($l = fgets($f, 100)) print strtoupper($l);
  fclose($f);

  ?>

miguel

--- End Message ---
--- Begin Message ---
I have the following code for a mySQL query in php:
 

$text = "sort_text";

$query = "SELECT code FROM links ORDER BY $text WHERE ".$text." like '".$l."%'";

$result = mysql_query($query) or die("Query failed");

When I do the query I get Query failed.

When I remove the sort parameter they are all printed correctly(except the fact the aren't in alphabetical order)

I am a newbie so be nice.

Any Ideas?

JJ Harrison
[EMAIL PROTECTED]
www.tececo.com

--- End Message ---
--- Begin Message ---
Well the ORDER BY is supposed to be after the WHERE statement.. Try that :)

Rick

"It is my ambition to say in ten sentences; what others say in a whole
book." - Friedrich Nietzsche

> From: [EMAIL PROTECTED]
> Date: Sun, 19 May 2002 13:05:19 +1000
> To: <[EMAIL PROTECTED]>
> Subject: [PHP] Problem with
> 
> I have the following code for a mySQL query in php:
> 
> $text = "sort_text";
> 
> $query = "SELECT code FROM links ORDER BY $text WHERE ".$text." like
> '".$l."%'";
> 
> $result = mysql_query($query) or die("Query failed");
> 
> When I do the query I get Query failed.
> 
> When I remove the sort parameter they are all printed correctly(except the
> fact the aren't in alphabetical order)
> 
> I am a newbie so be nice.
> 
> Any Ideas?
> 
> JJ Harrison
> [EMAIL PROTECTED]
> www.tececo.com
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php

--- End Message ---
--- Begin Message ---
Hi
I think this works :)

<?
$date1 = "1/1/2002";
$date2 = date("m/d/Y");
$time1 = strtotime($date1);
$time2 = strtotime($date2);
//get the first monday after date1
$first_monday = strtotime("first monday",$time1);
//check if its within date2
if($first_monday < $time2):
         //set count to 0 as we will go through the loop at least once
         $mondays = 0;
         $next_monday = $first_monday;
         //keep adding 7 days till we pass date2
         while($next_monday < $time2):
                 $next_monday = strtotime("+7 days",$next_monday);
                 $mondays ++;
         endwhile;
         echo "There are $mondays Mondays between $date1 and $date2 and the 
following monday is on ".date("m/d/Y",$next_monday)."<br>";
else:
         echo "there are no Mondays between $date1 and $date2 <br>";
endif;
?>
Tom



At 10:22 AM 19/05/2002, Josh Edwards wrote:
>Does anyone know  a good way to count the days between two dates. ie how
>many Mondays fall between two dates. As a starting  point I have calculated
>the start and end dates and the no of days b/w them.
>
>
>
>
>
>--
>PHP General Mailing List (http://www.php.net/)
>To unsubscribe, visit: http://www.php.net/unsub.php

--- End Message ---
--- Begin Message ---
On Sun, 19 May 2002, Josh Edwards wrote:
> Does anyone know  a good way to count the days between two dates. ie how
> many Mondays fall between two dates. As a starting  point I have calculated
> the start and end dates and the no of days b/w them.

Pretty much common sense, right? How about something like this:

  // $timestamp1 = starting date (unix timestamp)
  // $timestamp2 = ending date (unix timestamp)
  // $weekday = day we're counting (0 = Sunday, 1 = Monday, etc.)
  function weekdaysBetween ($timestamp1, $timestamp2, $weekday)
  {
    return floor(intval(($timestamp2 - $timestamp1) / 86400) / 7)
      + ((date('w', $timestamp1) <= $weekday) ? 1 : 0);
  }

miguel

--- End Message ---
--- Begin Message ---
Two columns in my PostgreSQL db are type 'date' (formatted 'YYYY-mm-dd'): 
'start_date' and 'expiry_date'. What I cannot seem to figure out is how to 
augment the 'expiry_date' either by 30 days, 60 days, or 1 year.

I've tried the date function in PHP (getdate) but the problem is that it 
appears to need a timestamp of "today". The dates that I'm trying to augment 
are sometimes a year or two ago.

This doesn't work:

$new_expiry_date = $expiry_date("Y-m-d", mktime(0,0,0, date(Y), date(m), 
date(d) + 60)));

I assume it's because the '$expiry_date' should be simply 'date', but that 
would give the current date which is not what is wanted. Is there anyway to 
set 'date' as '$expiry_date'?

Suggestions, admonitions, and general advice will be greatly appreciated. 
Btw, I've searched the archives, and haven't found anything quite on this 
topic.

Tia,
Andre

 
-- 
Please pray the Holy Rosary to end the holocaust of abortion.
Remember in your prayers the Holy Souls in Purgatory.

May God bless you abundantly in His love!
For a free Cenacle Scriptural Rosary Booklet: http://www.webhart.net/csrb/
--- End Message ---
--- Begin Message ---
Here's a nice article all about dates
http://www.phpbuilder.com/columns/akent20000610.ph
p3

On page 6 of that article it shows a function for
adding years, months, days ... to a date.

function DateAdd ($interval,  $number, $date)
{
$date_time_array  = getdate($date);

$hours =  $date_time_array["hours"];
$minutes =  $date_time_array["minutes"];
$seconds =  $date_time_array["seconds"];
$month =  $date_time_array["mon"];
$day =  $date_time_array["mday"];
$year =  $date_time_array["year"];

switch ($interval)
{
  case "yyyy":
    $year +=$number;
    break;
  case "q":
    $year +=($number*3);
    break;
  case "m":
    $month +=$number;
    break;
  case "y":
  case "d":
  case "w":
    $day+=$number;
    break;
  case "ww":
    $day+=($number*7);
    break;
  case "h":
    $hours+=$number;
    break;
  case "n":
    $minutes+=$number;
    break;
  case "s":
    $seconds+=$number;
    break;
}

$timestamp =  mktime($hours ,$minutes,
$seconds,$month ,$day, $year);
return $timestamp;
}

-----Original Message-----
From: Andre Dubuc [mailto:[EMAIL PROTECTED]]
Sent: May 19, 2002 12:03 AM
To: [EMAIL PROTECTED]
Subject: [PHP] Augmenting an old date


Two columns in my PostgreSQL db are type 'date'
(formatted 'YYYY-mm-dd'):
'start_date' and 'expiry_date'. What I cannot seem
to figure out is how to
augment the 'expiry_date' either by 30 days, 60
days, or 1 year.

I've tried the date function in PHP (getdate) but
the problem is that it
appears to need a timestamp of "today". The dates
that I'm trying to augment
are sometimes a year or two ago.

This doesn't work:

$new_expiry_date = $expiry_date("Y-m-d",
mktime(0,0,0, date(Y), date(m),
date(d) + 60)));

I assume it's because the '$expiry_date' should be
simply 'date', but that
would give the current date which is not what is
wanted. Is there anyway to
set 'date' as '$expiry_date'?

Suggestions, admonitions, and general advice will
be greatly appreciated.
Btw, I've searched the archives, and haven't found
anything quite on this
topic.

Tia,
Andre


--
Please pray the Holy Rosary to end the holocaust
of abortion.
Remember in your prayers the Holy Souls in
Purgatory.

May God bless you abundantly in His love!
For a free Cenacle Scriptural Rosary Booklet:
http://www.webhart.net/csrb/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit:
http://www.php.net/unsub.php


---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system
(http://www.grisoft.com).
Version: 6.0.361 / Virus Database: 199 - Release
Date: 07/05/02

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system
(http://www.grisoft.com).
Version: 6.0.361 / Virus Database: 199 - Release
Date: 07/05/02

--- End Message ---
--- Begin Message ---
Hi
You need to use the strtodate function which converts to a time stamp a 
date string and you can offset it by a number of days or whatever
something like this
<?

$start = "2002-01-01";
$expire = date("Y-m-d",strtotime("+30 days",strtotime($start)));
echo $expire."<br>";
?>

Tom



At 02:03 PM 19/05/2002, Andre Dubuc wrote:
>Two columns in my PostgreSQL db are type 'date' (formatted 'YYYY-mm-dd'):
>'start_date' and 'expiry_date'. What I cannot seem to figure out is how to
>augment the 'expiry_date' either by 30 days, 60 days, or 1 year.
>
>I've tried the date function in PHP (getdate) but the problem is that it
>appears to need a timestamp of "today". The dates that I'm trying to augment
>are sometimes a year or two ago.
>
>This doesn't work:
>
>$new_expiry_date = $expiry_date("Y-m-d", mktime(0,0,0, date(Y), date(m),
>date(d) + 60)));
>
>I assume it's because the '$expiry_date' should be simply 'date', but that
>would give the current date which is not what is wanted. Is there anyway to
>set 'date' as '$expiry_date'?
>
>Suggestions, admonitions, and general advice will be greatly appreciated.
>Btw, I've searched the archives, and haven't found anything quite on this
>topic.
>
>Tia,
>Andre
>
>
>--
>Please pray the Holy Rosary to end the holocaust of abortion.
>Remember in your prayers the Holy Souls in Purgatory.
>
>May God bless you abundantly in His love!
>For a free Cenacle Scriptural Rosary Booklet: http://www.webhart.net/csrb/
>
>--
>PHP General Mailing List (http://www.php.net/)
>To unsubscribe, visit: http://www.php.net/unsub.php

--- End Message ---
--- Begin Message ---
Hi
A slightly more efficeint way :)
<?

$start = "2002-01-01";
$expire = date("Y-m-d",strtotime("$start +30 days"));
echo $expire."<br>";
?>

Tom



At 02:03 PM 19/05/2002, Andre Dubuc wrote:
>Two columns in my PostgreSQL db are type 'date' (formatted 'YYYY-mm-dd'):
>'start_date' and 'expiry_date'. What I cannot seem to figure out is how to
>augment the 'expiry_date' either by 30 days, 60 days, or 1 year.
>
>I've tried the date function in PHP (getdate) but the problem is that it
>appears to need a timestamp of "today". The dates that I'm trying to augment
>are sometimes a year or two ago.
>
>This doesn't work:
>
>$new_expiry_date = $expiry_date("Y-m-d", mktime(0,0,0, date(Y), date(m),
>date(d) + 60)));
>
>I assume it's because the '$expiry_date' should be simply 'date', but that
>would give the current date which is not what is wanted. Is there anyway to
>set 'date' as '$expiry_date'?
>
>Suggestions, admonitions, and general advice will be greatly appreciated.
>Btw, I've searched the archives, and haven't found anything quite on this
>topic.
>
>Tia,
>Andre
>
>
>--
>Please pray the Holy Rosary to end the holocaust of abortion.
>Remember in your prayers the Holy Souls in Purgatory.
>
>May God bless you abundantly in His love!
>For a free Cenacle Scriptural Rosary Booklet: http://www.webhart.net/csrb/
>
>--
>PHP General Mailing List (http://www.php.net/)
>To unsubscribe, visit: http://www.php.net/unsub.php

--- End Message ---
--- Begin Message ---
Wow this is a pretty cool function.  I was playing
with it and you can add like +30 days + 99 seconds
together and it works.

-----Original Message-----
From: Tom Rogers [mailto:[EMAIL PROTECTED]]
Sent: May 19, 2002 1:07 AM
To: [EMAIL PROTECTED];
[EMAIL PROTECTED]
Subject: Re: [PHP] Augmenting an old date


Hi
A slightly more efficeint way :)
<?

$start = "2002-01-01";
$expire = date("Y-m-d",strtotime("$start +30
days"));
echo $expire."<br>";
?>

Tom



At 02:03 PM 19/05/2002, Andre Dubuc wrote:
>Two columns in my PostgreSQL db are type 'date'
(formatted 'YYYY-mm-dd'):
>'start_date' and 'expiry_date'. What I cannot
seem to figure out is how to
>augment the 'expiry_date' either by 30 days, 60
days, or 1 year.
>
>I've tried the date function in PHP (getdate) but
the problem is that it
>appears to need a timestamp of "today". The dates
that I'm trying to augment
>are sometimes a year or two ago.
>
>This doesn't work:
>
>$new_expiry_date = $expiry_date("Y-m-d",
mktime(0,0,0, date(Y), date(m),
>date(d) + 60)));
>
>I assume it's because the '$expiry_date' should
be simply 'date', but that
>would give the current date which is not what is
wanted. Is there anyway to
>set 'date' as '$expiry_date'?
>
>Suggestions, admonitions, and general advice will
be greatly appreciated.
>Btw, I've searched the archives, and haven't
found anything quite on this
>topic.
>
>Tia,
>Andre
>
>
>--
>Please pray the Holy Rosary to end the holocaust
of abortion.
>Remember in your prayers the Holy Souls in
Purgatory.
>
>May God bless you abundantly in His love!
>For a free Cenacle Scriptural Rosary Booklet:
http://www.webhart.net/csrb/
>
>--
>PHP General Mailing List (http://www.php.net/)
>To unsubscribe, visit:
http://www.php.net/unsub.php


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit:
http://www.php.net/unsub.php


---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system
(http://www.grisoft.com).
Version: 6.0.361 / Virus Database: 199 - Release
Date: 07/05/02

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system
(http://www.grisoft.com).
Version: 6.0.361 / Virus Database: 199 - Release
Date: 07/05/02

--- End Message ---
--- Begin Message ---
Thanks Tom, for the excellent help!

Seems like 'strtotime' function was what was needed!

Regards,
Andre

On Sunday 19 May 2002 01:06 am, you wrote:
> Hi
> A slightly more efficeint way :)
> <?
>
> $start = "2002-01-01";
> $expire = date("Y-m-d",strtotime("$start +30 days"));
> echo $expire."<br>";
> ?>
>
> Tom
>
> At 02:03 PM 19/05/2002, Andre Dubuc wrote:
> >Two columns in my PostgreSQL db are type 'date' (formatted 'YYYY-mm-dd'):
> >'start_date' and 'expiry_date'. What I cannot seem to figure out is how to
> >augment the 'expiry_date' either by 30 days, 60 days, or 1 year.
> >
> >I've tried the date function in PHP (getdate) but the problem is that it
> >appears to need a timestamp of "today". The dates that I'm trying to
> > augment are sometimes a year or two ago.
> >
> >This doesn't work:
> >
> >$new_expiry_date = $expiry_date("Y-m-d", mktime(0,0,0, date(Y), date(m),
> >date(d) + 60)));
> >
> >I assume it's because the '$expiry_date' should be simply 'date', but that
> >would give the current date which is not what is wanted. Is there anyway
> > to set 'date' as '$expiry_date'?
> >
> >Suggestions, admonitions, and general advice will be greatly appreciated.
> >Btw, I've searched the archives, and haven't found anything quite on this
> >topic.
> >
> >Tia,
> >Andre
> >
> >
> >--
> >Please pray the Holy Rosary to end the holocaust of abortion.
> >Remember in your prayers the Holy Souls in Purgatory.
> >
> >May God bless you abundantly in His love!
> >For a free Cenacle Scriptural Rosary Booklet: http://www.webhart.net/csrb/
> >
> >--
> >PHP General Mailing List (http://www.php.net/)
> >To unsubscribe, visit: http://www.php.net/unsub.php

-- 
Please pray the Holy Rosary to end the holocaust of abortion.
Remember in your prayers the Holy Souls in Purgatory.

May God bless you abundantly in His love!
For a free Cenacle Scriptural Rosary Booklet: http://www.webhart.net/csrb/
--- End Message ---
--- Begin Message ---
Dunno if this has been mentioned or fixed in the latest release (I'm using
PHP version 4.1.1) -- but, a script will not timeout until the sleep()
function has finished it's duration -- for example:

In my script, if I set "set_time_limit(30)" -- then later in the script I
call a "sleep(45)" -- the script will not timeout until 45 seconds later,
from the point at which the sleep() function was called.

Now, being a conscious programmer -- I'd probably never set my sleep()
function to exceed my default or defined timeout setting.  However, the
sleep value can be set via a $var -- and depending on what functions are
performed -- I can see how, when a programmer wants his script to timeout
within a certain amount of time and then it doesn't; can cause a problem --
in-fact, I can foree some sort of sleep-attack whereby a malicious hacker
figures out that a particular script on a particular website has a dynamic
$var for the sleep() function -- then s/he writes a script which calls the
page many times --- "injecting" the $var (say for example:
http://www.whateverweb.goo/home.php?t=65536, where $t is the time $var in
the script; sleep($t);"

Effectively; in this case, the scripts won't timeout for 18 some hours.
Filling up memory fast.

Just FYI.
Jason



--- End Message ---
--- Begin Message ---
I think I will try to standardize on the '' version, then. thank you.

Miguel Cruz wrote:
> 
> On Sat, 18 May 2002, Dennis Gearon wrote:
> > I appreciate all the good info on this subject, everybody.
> >
> > In looking the archives, I am still confused on one issue. Do **ALL**
> > databases treat \' or \" as escaped? Isn't the SQL standard character to
> > escape with a ' ?
> 
> I know that Oracle (at least as of v8) doesn't treat \' as escaped; you
> need to use the option "magic_quotes_sybase". And I know that MySQL is
> perfectly happy with either \' or ''.
> 
> miguel

-- 
-----------------------------------------------------------------
Joy is just a thing (to be).. raised on,
Love is just the way to Live and Die,
                        John Denver.
-----------------------------------------------------------------
He lost a friend, but kept his Memory (also John Denver),
                        Thank you...John Corones...my friend always.
-----------------------------------------------------------------
Look lovingly upon the present,
for it holds the only things that are forever true.
-----------------------------------------------------------------
                                Sincerely, Dennis Gearon (Kegley)
--- End Message ---
--- Begin Message ---
Im trying to get a final output to be '<item>' but Im unable to get 
working.  Could someone point me where Im going wrong.
Thanks

<?php

$a = '<item rdf:about="http://www.trini0.org";>';

$b = preg_replace("/(<item)(\s.*)(>)/i", "$1" . "$3", $a );
echo $b;

?>

--- End Message ---
--- Begin Message ---
I figured it out.  Change the last line to
echo htmlspecialchars($b);
and you'll get the proper output.

Gerard Samuel wrote:

> Im trying to get a final output to be '<item>' but Im unable to get 
> working.  Could someone point me where Im going wrong.
> Thanks
>
> <?php
>
> $a = '<item rdf:about="http://www.trini0.org";>';
>
> $b = preg_replace("/(<item)(\s.*)(>)/i", "$1" . "$3", $a );
> echo $b;
>
> ?>
>
>


--- End Message ---
--- Begin Message ---
Hello everyone,

Simple question: Will registering a variable twice, using
session_register(), reset the value of the variable to a different
value?

I just now started using the session_is_registered() function on all
sessions to see if they have been registered already, before I register
them yet again. But now I'm wondering about the inner workings of the
session itself. PHP.net doesn't do a very good job at explaining the
details. Thanks in advance for anyone's help.

Navid

--- End Message ---
--- Begin Message ---
On Sun, 19 May 2002, Navid Y. wrote:
> Simple question: Will registering a variable twice, using
> session_register(), reset the value of the variable to a different
> value?

session_register() adds a variable to the list of variables that are
tracked by the session. If the variable has already been registered, then
it has no effect.

miguel

--- End Message ---
--- Begin Message ---
Anyone know why http://www.php.net is soooooooooooo incredibly slow today
(all day) ???

Jason


--- End Message ---
--- Begin Message ---
On Sat, 18 May 2002, Jason Caldwell wrote:
> Anyone know why http://www.php.net is soooooooooooo incredibly slow today
> (all day) ???

Dunno, I've been doing my own armchair load balancing by typing
us2.php.net instead of php.net all day.

miguel

--- End Message ---
--- Begin Message ---
Seems to be an old main page on php.net too, us2.php.net shows 4.2.1
released, php.net doesn'.t :)

Mike
----- Original Message -----
From: "Miguel Cruz" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Sunday, May 19, 2002 1:35 AM
Subject: Re: [PHP] php.net sloooooooowwww


> On Sat, 18 May 2002, Jason Caldwell wrote:
> > Anyone know why http://www.php.net is soooooooooooo incredibly slow
today
> > (all day) ???
>
> Dunno, I've been doing my own armchair load balancing by typing
> us2.php.net instead of php.net all day.
>
> miguel
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--- End Message ---
--- Begin Message ---
Is there some place else I can download release 4.2.1 ??? www.php.net is
dead slow, and us2.php.net is taking forever to prompt me for the
download -- I keep getting hit with the "Page Cannot be Displayed" error.

Looking for the Win32 binary.

Thanks.
Jason


--- End Message ---
--- Begin Message ---
In article <[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] (Jason Caldwell) wrote:

> Is there some place else I can download release 4.2.1 ??? www.php.net is
> dead slow, and us2.php.net is taking forever to prompt me for the
> download -- I keep getting hit with the "Page Cannot be Displayed" error.

Have you tried any of the other mirrors, for example uk.php.net?  I'm not 
sure why us2 is giving you a problem, but hopefully other mirrors would not 
do the same...

-- 
CC
--- End Message ---
--- Begin Message ---
I'm using IIS5.0 -- and PHP 4.2.1 -- I think there is a compression setting
within IIS whereby the pages (before they are sent) are compressed, to be
decompressed and then displayed by the browser (pending, of course, if that
browser supports the HTTP 1.1 compression standard) --

My questions are;
1. How can I tell if IIS is compressing my PHP / HTML pages?
2. There are compression settings within the PHP.INI file -- what are these
about, do I use these instead of the IIS compression??

Thanks
Jason



--- End Message ---
--- Begin Message ---
On Sunday 19 May 2002 14:27, Jason Caldwell wrote:
> I'm using IIS5.0 -- and PHP 4.2.1 -- I think there is a compression setting
> within IIS whereby the pages (before they are sent) are compressed, to be
> decompressed and then displayed by the browser (pending, of course, if that
> browser supports the HTTP 1.1 compression standard) --
>
> My questions are;
> 1. How can I tell if IIS is compressing my PHP / HTML pages?

If you have NN4.X use view source, if the source is empty then compression is 
active. This is because NN4.X has a problem/bug in viewing the source of a 
compressed page.

If you're using some form of un*x then:

  lynx --mime_header http://www.domain.com/page.php

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.com.hk
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *

/*
QOTD:
        "I used to be an idealist, but I got mugged by reality."
*/

--- End Message ---
--- Begin Message ---
Can someone explain output_buffering to me?  I looked on php.net -- but
cannot find reference to it -- it's a setting in the PHP.INI file.

In my *production* .ini version, the output_buffering tag is set to 4096
(4k) -- what exactly is the intent of this tag?

What brought this question up was when I upgraded from 4.1.1 to 4.2.1, and
this time decided to use the production level .ini file -- when I ran a
script from my command line -- no output was appearing -- that is, I have
print() functions throughout my looping script -- and it wasn't
outputting -- I set the output_buffering tag to equal 0 -- and my looping
script now displays the text I want it to.

Is it that when a script exits or terminates that this 4k buffer gets
flushed out (in this case) to my screen?

What additional processing occurs if this tag is set to off, or 0 (zero) ?

Thanks
Jason



--- End Message ---
--- Begin Message ---
Forget the question -- I found the link I needed:
http://www.php.net/manual/en/function.ob-start.php




"Jason Caldwell" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> Can someone explain output_buffering to me?  I looked on php.net -- but
> cannot find reference to it -- it's a setting in the PHP.INI file.
>
> In my *production* .ini version, the output_buffering tag is set to 4096
> (4k) -- what exactly is the intent of this tag?
>
> What brought this question up was when I upgraded from 4.1.1 to 4.2.1, and
> this time decided to use the production level .ini file -- when I ran a
> script from my command line -- no output was appearing -- that is, I have
> print() functions throughout my looping script -- and it wasn't
> outputting -- I set the output_buffering tag to equal 0 -- and my looping
> script now displays the text I want it to.
>
> Is it that when a script exits or terminates that this 4k buffer gets
> flushed out (in this case) to my screen?
>
> What additional processing occurs if this tag is set to off, or 0 (zero) ?
>
> Thanks
> Jason
>
>
>


--- End Message ---
--- Begin Message ---
Is there a listing somewhere that shows which web browsers support
"gz-encoded" web pages?

Thanks
Jason


--- End Message ---
--- Begin Message ---
If Im not mistaken, all the current and recent Micro$oft, Netscape & 
friends support it.

Jason Caldwell wrote:

>Is there a listing somewhere that shows which web browsers support
>"gz-encoded" web pages?
>
>Thanks
>Jason
>
>
>
>  
>


--- End Message ---
--- Begin Message ---
Even Lynx does.

miguel

On Sun, 19 May 2002, Gerard Samuel wrote:
> If Im not mistaken, all the current and recent Micro$oft, Netscape & 
> friends support it.
> 
> Jason Caldwell wrote:
> 
> >Is there a listing somewhere that shows which web browsers support
> >"gz-encoded" web pages?
> >
> >Thanks
> >Jason
> >
> >
> >
> >  
> >
> 
> 
> 
> 

--- End Message ---
--- Begin Message ---
Hello all,

I'm trying to write an script to fetch e-mail and save whatever attachments there are.

Are there any articles or anywhere I can read about it?

Thanks,

Carlos Fernando Scheidecker Antunes
Linux User #207984

--- End Message ---
--- Begin Message ---
Though I use php quite a bit for non-web scripting, for incoming e-mail
you may be better off using perl.

Check the MailTools modules @ CPAN:

http://search.cpan.org/search?dist=MailTools

Specifically at Mail::Internet
http://search.cpan.org/doc/MARKOV/MailTools-1.44/Mail/Internet.pm

Good luck,
-J

On Sun, 19 May 2002 19:33:41 +1200, Carlos Fernando Scheidecker Antunes
wrote:

> Hello all,
> 
> I'm trying to write an script to fetch e-mail and save whatever
> attachments there are.
> 
> Are there any articles or anywhere I can read about it?
> 
> Thanks,
> 
> Carlos Fernando Scheidecker Antunes
> Linux User #207984
 

-- 
 Jason Morehouse ([EMAIL PROTECTED])
 Netconcepts LTD, Auckland, New Zealand    
 * Linux: because rebooting is for adding hardware.
--- End Message ---
--- Begin Message ---
Hello,

On 05/19/2002 04:33 AM, Carlos Fernando Scheidecker Antunes wrote:
> Hello all,
> 
> I'm trying to write an script to fetch e-mail and save whatever attachments there 
>are.
> 
> Are there any articles or anywhere I can read about it?

You may find here these two classes that seem to do what you need:

http://www.phpclasses.org/browse.html/package/347.html

http://www.phpclasses.org/browse.html/package/64.html

-- 

Regards,
Manuel Lemos

--- End Message ---
--- Begin Message ---
Hello,

On 05/19/2002 08:52 AM, Jason Morehouse wrote:
> Though I use php quite a bit for non-web scripting, for incoming e-mail
> you may be better off using perl.
> 
> Check the MailTools modules @ CPAN:
> 
> http://search.cpan.org/search?dist=MailTools
> 
> Specifically at Mail::Internet
> http://search.cpan.org/doc/MARKOV/MailTools-1.44/Mail/Internet.pm

And why do you think anybody would come to a PHP list to know about a 
Perl solution?

It is not that there are no PHP solutions for that purpose.

Manuel Lemos

--- End Message ---
--- Begin Message ---
Hello All,

I want to return a gif from a php script. I want it to not be cachable
"anywhere" not browsers, proxys etc. Actualy what I want to do is pass an
existing .gif file as the output and do some database manipulation whilst I
do so.

A bit like a hit counter type system.

<img src="counter.php?site=1">

Any help as to where I should start looking would be greatly appreciated.

Henry.

TIA.


--- End Message ---
--- Begin Message ---
Hi,

I'm making an script to make an PDF file width 2 windows fonts (Times new
Roman and BmOCRB).

When I add the second font the PDF file issn't created.

here ar my font dec.

$font = pdf_findfont($pdf, "Times new roman", "winansi", 1);
if ($font) {
           pdf_setfont($pdf, $font, 12);
}

etc,etc,etc

pdf_setfont($pdf, $font, 20); // till here it's ok

etc,etc,etc

$font2 = pdf_findfont($pdf, "bmocrb", "winansi", 1); // Here I get no error
or any warning
if ($font2) {
           pdf_setfont($pdf, $font2, 12);
}


--

Maurice


--- End Message ---
--- Begin Message ---

I want to refrech a part of my page (or the whole page) using PHP.
Periodically, using a time delay.
Should I use frames?

Also I tried to use "header (...)" calling the same page with different name
(and then back to the same page) but I got the warning:
"header already send".
I tried also "Location" and "pagename.php,FALSE" but also with no results.

I want to refresh some pictures (jpg) but I don't want to use multi picture
jpg as the page will be to large.


Makis Savaidis


--- End Message ---
--- Begin Message ---
On Sunday 19 May 2002 18:03, savaidis wrote:
> I want to refrech a part of my page (or the whole page) using PHP.
> Periodically, using a time delay.
> Should I use frames?

You cannot refresh part of a page without resending the whole page. You can 
use frames.

> Also I tried to use "header (...)" calling the same page with different
> name (and then back to the same page) but I got the warning:
> "header already send".

*Read* the manual and see what it says about header() and "header already 
send".

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.com.hk
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *

/*
A great many people think they are thinking when they are merely
rearranging their prejudices.
                -- William James
*/

--- End Message ---
--- Begin Message ---
Can someone look and help

I have a  function that returns the date in this format
[10/Apr/2002:01:17:27 +1000] but I'm having trouble returning the last date
in the file.

$totalhits = count($fcontents);
$filename = ("combined_log");   //open file

$fcontents = file($filename);   //read into array
 //print_r($fcontents);

$limit = 1;
for ($i = 0; $i < $limit; $i++)  //loop
 {
 $line = $fcontents[$i];
  if (!empty($line))

 {
  $currentdate = getmydate($line);  //call function that returns first date.
This is OK
  $currentdate = substr($currentdate, 1);
  $currentdate= substr_replace($currentdate, " ", -15);
   echo "First day of access " .$currentdate;

  $lastdate = getmydate($fcontents[count($fcontents)-1]);
//**************This is returning nothing?
  $lastdate = substr($lastdate, 1);
  $lastdate= substr_replace($lastdate, " ", -15);
   echo "<br>Last day of access " .$lastdate;
 }
 }



--- End Message ---
--- Begin Message ---
On Sunday 19 May 2002 18:21, Josh Edwards wrote:
> Can someone look and help
>
> I have a  function that returns the date in this format
> [10/Apr/2002:01:17:27 +1000] but I'm having trouble returning the last date
> in the file.

[snip]

>   $lastdate = getmydate($fcontents[count($fcontents)-1]);
> //**************This is returning nothing?

If that's not returning anything, did you you try breaking down in smaller 
statements? Build it up step by step and when it breaks you'll know what the 
problem is.

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.com.hk
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *

/*
Flourescent lights are generating negative ions. If turning them off doesn't 
work, take them out and put tin foil on the ends.
*/

--- End Message ---
--- Begin Message ---
greetings...
Webyog has released mySQLyog, a win32 based Query
analyzer. Its FREE and gives all the features that a
mysql developer can ask for by a query analyzer.
please visit www.webyog.com
you can execute query of results of more than 100000
records, supports multiple query execution and you can
export your data into XML, HTML and CSV and can also
import form a text file.
It also allows you to excute last query and lets you
add your favourite query in a personal folder with one
click of mouse. So you dont have to save it and open
it.
Please take a look at it and feel free to send your
suggestions to [EMAIL PROTECTED]
Ritesh


__________________________________________________
Do You Yahoo!?
LAUNCH - Your Yahoo! Music Experience
http://launch.yahoo.com
--- End Message ---
--- Begin Message ---
Hi there,

I do have trouble with finding out if a file is a jpeg or not.  This is the
command I am using:

 $_FILES[picture_location][type]

works fine exept in one case: With Photoshop 6.0 I do open the jpeg (which
workes fine) an save as jpeg as another file name. Then upload the new file.
This returns a type called:

application/octet-stream

So what is this type anyway. I do know jpeg and jpg and pjpeg but
octed-stream?!

Thanx for any help on that,

Andy


--- End Message ---

Reply via email to