php-general Digest 12 Nov 2012 06:58:07 -0000 Issue 8036

Topics (messages 319673 through 319686):

Re: memory allocation error
        319673 by: Sebastian Krebs

Date comparison going wrong, wrong, wrong
        319674 by: Terry Ally (Gmail)
        319676 by: shiplu
        319677 by: Stuart Dallas
        319679 by: Terry Ally (Gmail)
        319680 by: Stuart Dallas
        319681 by: Stuart Dallas
        319682 by: Terry Ally (Gmail)
        319683 by: Stuart Dallas
        319684 by: Jim Giner
        319685 by: Jim Giner
        319686 by: Maciek Sokolewicz

Re: Rest Authentication
        319675 by: Stuart Dallas
        319678 by: shiplu

Administrivia:

To subscribe to the digest, e-mail:
        php-general-digest-subscr...@lists.php.net

To unsubscribe from the digest, e-mail:
        php-general-digest-unsubscr...@lists.php.net

To post to the list, e-mail:
        php-gene...@lists.php.net


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

Do you use a custom error handler?

Regards,
Sebastian


2012/11/11 Carol Peck <carolap...@gmail.com>

> Hi all,
> I've been chasing around a memory allocation error for some time and can't
> figure it out.  It is somewhat random - I can run the script 3 times and
> then it will happen, or sometimes the first time.
>
> It happens at the very end of a script, actually after the script has
> finished running.  I will see the following after the closing </html> tag:
>
> Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to
> allocate 494142432 bytes) in Unknown on line 0
>
> Just previous to this my mem usage is 3772104
>
>
> The script itself does some database work (deletes, inserts, selects) but
> nothing very heavy and writes out an XML file.  I use adodb 5.18, the
> server is PHP 5.3.18 (this was updated recently) and it is a VPS on
> inmotionhosting.com.
>
> As you can see, the memory limit is 256M so it's really high and I never
> see that I'm using more than 4M.  The error doesn't fall through my error
> class - I'm assuming that's because it is happening after the script is
> complete.
>
> I am completely out of ideas on how to trap it or figure it out.
> Any ideas would be appreciated!
>
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
github.com/KingCrunch

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

I am having a problem with comparing time. I am using the following:

$todaydate = date("D, M jS, Y g:i:s a");
$showenddate = date("D, M jS, Y g:i:s a",
strtotime($showsRecord['end_date']));

if ($todaydate > $showenddate):
    echo "The date of the show has not yet arrived";
else:
    echo "The show has ended";
endif;

The problem that I am encountering is that PHP is rendering the reverse of
the equation. For example:

If today's date is *11 Nov 2012* and the show's end date is *18 Nov 2012*,
the message that I am getting is *the show has ended* which is wrong. A
test example is at http://www.lakesidesurrey.co.uk/test.php.

You can also me what I am doing wrong?

Thanks
Terry

--- End Message ---
--- Begin Message ---
You can always use timestamp which is integer.

$todaydate = time();
$showenddate = strtotime($showsRecord['end_date']);


On Mon, Nov 12, 2012 at 12:30 AM, Terry Ally (Gmail) <terrya...@gmail.com>wrote:

> Hi all,
>
> I am having a problem with comparing time. I am using the following:
>
> $todaydate = date("D, M jS, Y g:i:s a");
> $showenddate = date("D, M jS, Y g:i:s a",
> strtotime($showsRecord['end_date']));
>
> if ($todaydate > $showenddate):
>     echo "The date of the show has not yet arrived";
> else:
>     echo "The show has ended";
> endif;
>
> The problem that I am encountering is that PHP is rendering the reverse of
> the equation. For example:
>
> If today's date is *11 Nov 2012* and the show's end date is *18 Nov 2012*,
> the message that I am getting is *the show has ended* which is wrong. A
> test example is at http://www.lakesidesurrey.co.uk/test.php.
>
> You can also me what I am doing wrong?
>
> Thanks
> Terry
>



-- 
Shiplu.Mokadd.im
ImgSign.com | A dynamic signature machine
Innovation distinguishes between follower and leader

--- End Message ---
--- Begin Message ---
On 11 Nov 2012, at 18:30, "Terry Ally (Gmail)" <terrya...@gmail.com> wrote:

> I am having a problem with comparing time. I am using the following:
> 
> $todaydate = date("D, M jS, Y g:i:s a");
> $showenddate = date("D, M jS, Y g:i:s a",
> strtotime($showsRecord['end_date']));

The date function returns a string.

> if ($todaydate > $showenddate):
>    echo "The date of the show has not yet arrived";
> else:
>    echo "The show has ended";
> endif;

So here you are comparing two strings; PHP has no idea they are dates.

> The problem that I am encountering is that PHP is rendering the reverse of
> the equation. For example:
> 
> If today's date is *11 Nov 2012* and the show's end date is *18 Nov 2012*,
> the message that I am getting is *the show has ended* which is wrong. A
> test example is at http://www.lakesidesurrey.co.uk/test.php.
> 
> You can also me what I am doing wrong?


Compare timestamps instead, i.e. time() for the current time, and what you get 
back from strtotime for the end date.

-Stuart

-- 
Stuart Dallas
3ft9 Ltd
http://3ft9.com/

--- End Message ---
--- Begin Message ---
Hi Shiplu and Stuart,

Comparing timestamps was my first option. I've reinstated it. Have a look
at http://www.lakesidesurrey.co.uk/test.php (show_source included) and you
will see that PHP is still outputting the wrong thing.

I just can't figure out what's wrong.

Terry

On 11 November 2012 18:48, shiplu <shiplu....@gmail.com> wrote:

> You can always use timestamp which is integer.
>
> $todaydate = time();
> $showenddate = strtotime($showsRecord['end_date']);
>
>
> On Mon, Nov 12, 2012 at 12:30 AM, Terry Ally (Gmail) 
> <terrya...@gmail.com>wrote:
>
>> Hi all,
>>
>> I am having a problem with comparing time. I am using the following:
>>
>> $todaydate = date("D, M jS, Y g:i:s a");
>> $showenddate = date("D, M jS, Y g:i:s a",
>> strtotime($showsRecord['end_date']));
>>
>> if ($todaydate > $showenddate):
>>     echo "The date of the show has not yet arrived";
>> else:
>>     echo "The show has ended";
>> endif;
>>
>> The problem that I am encountering is that PHP is rendering the reverse of
>> the equation. For example:
>>
>> If today's date is *11 Nov 2012* and the show's end date is *18 Nov 2012*,
>> the message that I am getting is *the show has ended* which is wrong. A
>>
>> test example is at http://www.lakesidesurrey.co.uk/test.php.
>>
>> You can also me what I am doing wrong?
>>
>> Thanks
>> Terry
>>
>
>
>
> --
> Shiplu.Mokadd.im
> ImgSign.com | A dynamic signature machine
> Innovation distinguishes between follower and leader
>
>


-- 
*Terry Ally*
Twitter.com/terryally
Facebook.com/terryally
~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~
To print or not to print this email is the environmentally-searching
question!
Which has the highest ecological cost? A sheet of paper or constantly
switching on your computer and connecting to the Internet to read your
email?

--- End Message ---
--- Begin Message ---
On 11 Nov 2012, at 19:00, "Terry Ally (Gmail)" <terrya...@gmail.com> wrote:

> Hi Shiplu and Stuart,
> 
> Comparing timestamps was my first option. I've reinstated it. Have a look
> at http://www.lakesidesurrey.co.uk/test.php (show_source included) and you
> will see that PHP is still outputting the wrong thing.
> 
> I just can't figure out what's wrong.

Your comparison is backwards:

if ($todaydate > $showenddate):

should be

if ($todaydate < $showenddate):

-Stuart

-- 
Stuart Dallas
3ft9 Ltd
http://3ft9.com/

> On 11 November 2012 18:48, shiplu <shiplu....@gmail.com> wrote:
> 
>> You can always use timestamp which is integer.
>> 
>> $todaydate = time();
>> $showenddate = strtotime($showsRecord['end_date']);
>> 
>> 
>> On Mon, Nov 12, 2012 at 12:30 AM, Terry Ally (Gmail) 
>> <terrya...@gmail.com>wrote:
>> 
>>> Hi all,
>>> 
>>> I am having a problem with comparing time. I am using the following:
>>> 
>>> $todaydate = date("D, M jS, Y g:i:s a");
>>> $showenddate = date("D, M jS, Y g:i:s a",
>>> strtotime($showsRecord['end_date']));
>>> 
>>> if ($todaydate > $showenddate):
>>>    echo "The date of the show has not yet arrived";
>>> else:
>>>    echo "The show has ended";
>>> endif;
>>> 
>>> The problem that I am encountering is that PHP is rendering the reverse of
>>> the equation. For example:
>>> 
>>> If today's date is *11 Nov 2012* and the show's end date is *18 Nov 2012*,
>>> the message that I am getting is *the show has ended* which is wrong. A
>>> 
>>> test example is at http://www.lakesidesurrey.co.uk/test.php.
>>> 
>>> You can also me what I am doing wrong?
>>> 
>>> Thanks
>>> Terry
>>> 
>> 
>> 
>> 
>> --
>> Shiplu.Mokadd.im
>> ImgSign.com | A dynamic signature machine
>> Innovation distinguishes between follower and leader
>> 
>> 
> 
> 
> -- 
> *Terry Ally*
> Twitter.com/terryally
> Facebook.com/terryally
> ~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~
> To print or not to print this email is the environmentally-searching
> question!
> Which has the highest ecological cost? A sheet of paper or constantly
> switching on your computer and connecting to the Internet to read your
> email?


--- End Message ---
--- Begin Message ---
Please include the list when replying.

On 11 Nov 2012, at 19:08, "Terry Ally (Gmail)" <terrya...@gmail.com> wrote:

> What I want is the reverse.
> 
> I want that if people attempt to access the show page after the show has 
> ended that it triggers an error which takes it to another page. The actual 
> conditional statement is as follows (which I will replace with timestamp):
> 
>       $todaydate = date("D, M jS, Y g:i:s a");
>       $showenddate = date("D, M jS, Y g:i:s a", 
> strtotime($showsRecord['end_date']));
> if ($todaydate > $showenddate) {
>       header( 'Location: eventdetails_error.php' ) ;
>       }

This is what you have:

if ($todaydate > $showenddate): 
    echo "The date of the show has not yet arrived<br>"; 
else:  
    echo "The show has ended<br>"; 
endif; 

That says: if the current time is later than the end date of the show, tell 
them the date of the show hasn't arrived yet.

What you mean is: if the current time is later than the end of the show, tell 
them the show has ended.

if ($todaydate < $showenddate): 
    echo "The date of the show has not yet arrived<br>"; 
else:  
    echo "The show has ended<br>"; 
endif; 

It's a simple logic error.

-Stuart

-- 
Stuart Dallas
3ft9 Ltd
http://3ft9.com/

> On 11 November 2012 19:04, Stuart Dallas <stu...@3ft9.com> wrote:
> On 11 Nov 2012, at 19:00, "Terry Ally (Gmail)" <terrya...@gmail.com> wrote:
> 
> > Hi Shiplu and Stuart,
> >
> > Comparing timestamps was my first option. I've reinstated it. Have a look
> > at http://www.lakesidesurrey.co.uk/test.php (show_source included) and you
> > will see that PHP is still outputting the wrong thing.
> >
> > I just can't figure out what's wrong.
> 
> Your comparison is backwards:
> 
> if ($todaydate > $showenddate):
> 
> should be
> 
> if ($todaydate < $showenddate):
> 
> -Stuart
> 
> --
> Stuart Dallas
> 3ft9 Ltd
> http://3ft9.com/
> 
> > On 11 November 2012 18:48, shiplu <shiplu....@gmail.com> wrote:
> >
> >> You can always use timestamp which is integer.
> >>
> >> $todaydate = time();
> >> $showenddate = strtotime($showsRecord['end_date']);
> >>
> >>
> >> On Mon, Nov 12, 2012 at 12:30 AM, Terry Ally (Gmail) 
> >> <terrya...@gmail.com>wrote:
> >>
> >>> Hi all,
> >>>
> >>> I am having a problem with comparing time. I am using the following:
> >>>
> >>> $todaydate = date("D, M jS, Y g:i:s a");
> >>> $showenddate = date("D, M jS, Y g:i:s a",
> >>> strtotime($showsRecord['end_date']));
> >>>
> >>> if ($todaydate > $showenddate):
> >>>    echo "The date of the show has not yet arrived";
> >>> else:
> >>>    echo "The show has ended";
> >>> endif;
> >>>
> >>> The problem that I am encountering is that PHP is rendering the reverse of
> >>> the equation. For example:
> >>>
> >>> If today's date is *11 Nov 2012* and the show's end date is *18 Nov 2012*,
> >>> the message that I am getting is *the show has ended* which is wrong. A
> >>>
> >>> test example is at http://www.lakesidesurrey.co.uk/test.php.
> >>>
> >>> You can also me what I am doing wrong?
> >>>
> >>> Thanks
> >>> Terry
> >>>
> >>
> >>
> >>
> >> --
> >> Shiplu.Mokadd.im
> >> ImgSign.com | A dynamic signature machine
> >> Innovation distinguishes between follower and leader
> >>
> >>
> >
> >
> > --
> > *Terry Ally*
> > Twitter.com/terryally
> > Facebook.com/terryally
> > ~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~
> > To print or not to print this email is the environmentally-searching
> > question!
> > Which has the highest ecological cost? A sheet of paper or constantly
> > switching on your computer and connecting to the Internet to read your
> > email?
> 
> 
> 
> 
> -- 
> Terry Ally
> Twitter.com/terryally
> Facebook.com/terryally
> ~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~
> To print or not to print this email is the environmentally-searching question!
> Which has the highest ecological cost? A sheet of paper or constantly 
> switching on your computer and connecting to the Internet to read your email? 
> 


--- End Message ---
--- Begin Message ---
Stuart,

I reversed it as you suggested and every future show is displaying as
having ended.

Terry

On 11 November 2012 19:11, Stuart Dallas <stu...@3ft9.com> wrote:

> Please include the list when replying.
>
> On 11 Nov 2012, at 19:08, "Terry Ally (Gmail)" <terrya...@gmail.com>
> wrote:
>
> > What I want is the reverse.
> >
> > I want that if people attempt to access the show page after the show has
> ended that it triggers an error which takes it to another page. The actual
> conditional statement is as follows (which I will replace with timestamp):
> >
> >       $todaydate = date("D, M jS, Y g:i:s a");
> >       $showenddate = date("D, M jS, Y g:i:s a",
> strtotime($showsRecord['end_date']));
> > if ($todaydate > $showenddate) {
> >       header( 'Location: eventdetails_error.php' ) ;
> >       }
>
> This is what you have:
>
> if ($todaydate > $showenddate):
>     echo "The date of the show has not yet arrived<br>";
> else:
>     echo "The show has ended<br>";
> endif;
>
> That says: if the current time is later than the end date of the show,
> tell them the date of the show hasn't arrived yet.
>
> What you mean is: if the current time is later than the end of the show,
> tell them the show has ended.
>
> if ($todaydate < $showenddate):
>     echo "The date of the show has not yet arrived<br>";
> else:
>     echo "The show has ended<br>";
> endif;
>
> It's a simple logic error.
>
> -Stuart
>
> --
> Stuart Dallas
> 3ft9 Ltd
> http://3ft9.com/
>
> > On 11 November 2012 19:04, Stuart Dallas <stu...@3ft9.com> wrote:
> > On 11 Nov 2012, at 19:00, "Terry Ally (Gmail)" <terrya...@gmail.com>
> wrote:
> >
> > > Hi Shiplu and Stuart,
> > >
> > > Comparing timestamps was my first option. I've reinstated it. Have a
> look
> > > at http://www.lakesidesurrey.co.uk/test.php (show_source included)
> and you
> > > will see that PHP is still outputting the wrong thing.
> > >
> > > I just can't figure out what's wrong.
> >
> > Your comparison is backwards:
> >
> > if ($todaydate > $showenddate):
> >
> > should be
> >
> > if ($todaydate < $showenddate):
> >
> > -Stuart
> >
> > --
> > Stuart Dallas
> > 3ft9 Ltd
> > http://3ft9.com/
> >
> > > On 11 November 2012 18:48, shiplu <shiplu....@gmail.com> wrote:
> > >
> > >> You can always use timestamp which is integer.
> > >>
> > >> $todaydate = time();
> > >> $showenddate = strtotime($showsRecord['end_date']);
> > >>
> > >>
> > >> On Mon, Nov 12, 2012 at 12:30 AM, Terry Ally (Gmail) <
> terrya...@gmail.com>wrote:
> > >>
> > >>> Hi all,
> > >>>
> > >>> I am having a problem with comparing time. I am using the following:
> > >>>
> > >>> $todaydate = date("D, M jS, Y g:i:s a");
> > >>> $showenddate = date("D, M jS, Y g:i:s a",
> > >>> strtotime($showsRecord['end_date']));
> > >>>
> > >>> if ($todaydate > $showenddate):
> > >>>    echo "The date of the show has not yet arrived";
> > >>> else:
> > >>>    echo "The show has ended";
> > >>> endif;
> > >>>
> > >>> The problem that I am encountering is that PHP is rendering the
> reverse of
> > >>> the equation. For example:
> > >>>
> > >>> If today's date is *11 Nov 2012* and the show's end date is *18 Nov
> 2012*,
> > >>> the message that I am getting is *the show has ended* which is
> wrong. A
> > >>>
> > >>> test example is at http://www.lakesidesurrey.co.uk/test.php.
> > >>>
> > >>> You can also me what I am doing wrong?
> > >>>
> > >>> Thanks
> > >>> Terry
> > >>>
> > >>
> > >>
> > >>
> > >> --
> > >> Shiplu.Mokadd.im
> > >> ImgSign.com | A dynamic signature machine
> > >> Innovation distinguishes between follower and leader
> > >>
> > >>
> > >
> > >
> > > --
> > > *Terry Ally*
> > > Twitter.com/terryally
> > > Facebook.com/terryally
> > > ~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~
> > > To print or not to print this email is the environmentally-searching
> > > question!
> > > Which has the highest ecological cost? A sheet of paper or constantly
> > > switching on your computer and connecting to the Internet to read your
> > > email?
> >
> >
> >
> >
> > --
> > Terry Ally
> > Twitter.com/terryally
> > Facebook.com/terryally
> > ~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~
> > To print or not to print this email is the environmentally-searching
> question!
> > Which has the highest ecological cost? A sheet of paper or constantly
> switching on your computer and connecting to the Internet to read your
> email?
> >
>
>


-- 
*Terry Ally*
Twitter.com/terryally
Facebook.com/terryally
~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~
To print or not to print this email is the environmentally-searching
question!
Which has the highest ecological cost? A sheet of paper or constantly
switching on your computer and connecting to the Internet to read your
email?

--- End Message ---
--- Begin Message ---
On 11 Nov 2012, at 19:24, "Terry Ally (Gmail)" <terrya...@gmail.com> wrote:

> I reversed it as you suggested and every future show is displaying as having 
> ended.

In that case the code you're showing us is not the code you're running, because 
that's the obvious error in test.php.

-Stuart

-- 
Stuart Dallas
3ft9 Ltd
http://3ft9.com/

> On 11 November 2012 19:11, Stuart Dallas <stu...@3ft9.com> wrote:
> Please include the list when replying.
> 
> On 11 Nov 2012, at 19:08, "Terry Ally (Gmail)" <terrya...@gmail.com> wrote:
> 
> > What I want is the reverse.
> >
> > I want that if people attempt to access the show page after the show has 
> > ended that it triggers an error which takes it to another page. The actual 
> > conditional statement is as follows (which I will replace with timestamp):
> >
> >       $todaydate = date("D, M jS, Y g:i:s a");
> >       $showenddate = date("D, M jS, Y g:i:s a", 
> > strtotime($showsRecord['end_date']));
> > if ($todaydate > $showenddate) {
> >       header( 'Location: eventdetails_error.php' ) ;
> >       }
> 
> This is what you have:
> 
> if ($todaydate > $showenddate):
>     echo "The date of the show has not yet arrived<br>";
> else:
>     echo "The show has ended<br>";
> endif;
> 
> That says: if the current time is later than the end date of the show, tell 
> them the date of the show hasn't arrived yet.
> 
> What you mean is: if the current time is later than the end of the show, tell 
> them the show has ended.
> 
> if ($todaydate < $showenddate):
>     echo "The date of the show has not yet arrived<br>";
> else:
>     echo "The show has ended<br>";
> endif;
> 
> It's a simple logic error.
> 
> -Stuart
> 
> --
> Stuart Dallas
> 3ft9 Ltd
> http://3ft9.com/
> 
> > On 11 November 2012 19:04, Stuart Dallas <stu...@3ft9.com> wrote:
> > On 11 Nov 2012, at 19:00, "Terry Ally (Gmail)" <terrya...@gmail.com> wrote:
> >
> > > Hi Shiplu and Stuart,
> > >
> > > Comparing timestamps was my first option. I've reinstated it. Have a look
> > > at http://www.lakesidesurrey.co.uk/test.php (show_source included) and you
> > > will see that PHP is still outputting the wrong thing.
> > >
> > > I just can't figure out what's wrong.
> >
> > Your comparison is backwards:
> >
> > if ($todaydate > $showenddate):
> >
> > should be
> >
> > if ($todaydate < $showenddate):
> >
> > -Stuart
> >
> > --
> > Stuart Dallas
> > 3ft9 Ltd
> > http://3ft9.com/
> >
> > > On 11 November 2012 18:48, shiplu <shiplu....@gmail.com> wrote:
> > >
> > >> You can always use timestamp which is integer.
> > >>
> > >> $todaydate = time();
> > >> $showenddate = strtotime($showsRecord['end_date']);
> > >>
> > >>
> > >> On Mon, Nov 12, 2012 at 12:30 AM, Terry Ally (Gmail) 
> > >> <terrya...@gmail.com>wrote:
> > >>
> > >>> Hi all,
> > >>>
> > >>> I am having a problem with comparing time. I am using the following:
> > >>>
> > >>> $todaydate = date("D, M jS, Y g:i:s a");
> > >>> $showenddate = date("D, M jS, Y g:i:s a",
> > >>> strtotime($showsRecord['end_date']));
> > >>>
> > >>> if ($todaydate > $showenddate):
> > >>>    echo "The date of the show has not yet arrived";
> > >>> else:
> > >>>    echo "The show has ended";
> > >>> endif;
> > >>>
> > >>> The problem that I am encountering is that PHP is rendering the reverse 
> > >>> of
> > >>> the equation. For example:
> > >>>
> > >>> If today's date is *11 Nov 2012* and the show's end date is *18 Nov 
> > >>> 2012*,
> > >>> the message that I am getting is *the show has ended* which is wrong. A
> > >>>
> > >>> test example is at http://www.lakesidesurrey.co.uk/test.php.
> > >>>
> > >>> You can also me what I am doing wrong?
> > >>>
> > >>> Thanks
> > >>> Terry
> > >>>
> > >>
> > >>
> > >>
> > >> --
> > >> Shiplu.Mokadd.im
> > >> ImgSign.com | A dynamic signature machine
> > >> Innovation distinguishes between follower and leader
> > >>
> > >>
> > >
> > >
> > > --
> > > *Terry Ally*
> > > Twitter.com/terryally
> > > Facebook.com/terryally
> > > ~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~
> > > To print or not to print this email is the environmentally-searching
> > > question!
> > > Which has the highest ecological cost? A sheet of paper or constantly
> > > switching on your computer and connecting to the Internet to read your
> > > email?
> >
> >
> >
> >
> > --
> > Terry Ally
> > Twitter.com/terryally
> > Facebook.com/terryally
> > ~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~
> > To print or not to print this email is the environmentally-searching 
> > question!
> > Which has the highest ecological cost? A sheet of paper or constantly 
> > switching on your computer and connecting to the Internet to read your 
> > email?
> >
> 
> 
> 
> 
> -- 
> Terry Ally
> Twitter.com/terryally
> Facebook.com/terryally
> ~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~
> To print or not to print this email is the environmentally-searching question!
> Which has the highest ecological cost? A sheet of paper or constantly 
> switching on your computer and connecting to the Internet to read your email? 
> 


--- End Message ---
--- Begin Message ---
On 11/11/2012 1:30 PM, Terry Ally (Gmail) wrote:
Hi all,

I am having a problem with comparing time. I am using the following:

$todaydate = date("D, M jS, Y g:i:s a");
$showenddate = date("D, M jS, Y g:i:s a",
strtotime($showsRecord['end_date']));

if ($todaydate > $showenddate):
     echo "The date of the show has not yet arrived";
else:
     echo "The show has ended";
endif;

The problem that I am encountering is that PHP is rendering the reverse of
the equation. For example:

If today's date is *11 Nov 2012* and the show's end date is *18 Nov 2012*,
the message that I am getting is *the show has ended* which is wrong. A
test example is at http://www.lakesidesurrey.co.uk/test.php.

You can also me what I am doing wrong?

Thanks
Terry

Besides the minor fact that the code has syntax errors, the problem with it is your if is backwrads. The facts are: today is less than end date, so your if should show "The show has ended" since you are asking if today IS GREATER than the end date.
--- End Message ---
--- Begin Message ---

BTW - this is the code I used to test out your process:

<?
$dt_format = "D, M jS, Y g:i:s a";
$todaydate = date($dt_format);
$showenddate = strtotime("11/18/12 16:00:00");
if ($todaydate > $showenddate)
    echo "The date of the show has not yet arrived";
else
    echo "The show has ended";

--- End Message ---
--- Begin Message ---
On 11-11-2012 22:47, Jim Giner wrote:
Besides the minor fact that the code has syntax errors, the problem with
it is your if is backwrads.  The facts are: today is less than end date,
so your if should show "The show has ended" since you are asking if
today IS GREATER than the end date.

BTW - this is the code I used to test out your process:

<?
$dt_format = "D, M jS, Y g:i:s a";
$todaydate = date($dt_format);
$showenddate = strtotime("11/18/12 16:00:00");
if ($todaydate > $showenddate)
    echo "The date of the show has not yet arrived";
else
    echo "The show has ended";


Not only is the logic wrong, but date returns a string, while strtotime returns an int. Comparing those two to eachother is just... wrong.
Comparing 2 integers and saying one is bigger than the other: ok
Comparing a string and an integer, saying one is bigger than the other: recipe for failure.
--- End Message ---
--- Begin Message ---
On 10 Nov 2012, at 23:28, Adam Tong <adam.to...@gmail.com> wrote:

> I am developing a REST API. I found the Slim micro-framework usefull.
> I need authentication of course, and I see that Slim does not provide
> authentication for Rest. Is there any lightweight alternative to
> manually implementing http authentication and the hassle of apache
> configurations?

HTTP auth doesn't need to involve the web server at all:

http://stut.net/2012/11/11/snippet-http-authentication/

-Stuart

-- 
Stuart Dallas
3ft9 Ltd
http://3ft9.com/

--- End Message ---
--- Begin Message ---
Its rather better to auto using a apikey. You'll provide this apikey on the
website where user registers their application.


On Mon, Nov 12, 2012 at 12:45 AM, Stuart Dallas <stu...@3ft9.com> wrote:

> On 10 Nov 2012, at 23:28, Adam Tong <adam.to...@gmail.com> wrote:
>
> > I am developing a REST API. I found the Slim micro-framework usefull.
> > I need authentication of course, and I see that Slim does not provide
> > authentication for Rest. Is there any lightweight alternative to
> > manually implementing http authentication and the hassle of apache
> > configurations?
>
> HTTP auth doesn't need to involve the web server at all:
>
> http://stut.net/2012/11/11/snippet-http-authentication/
>
> -Stuart
>
> --
> Stuart Dallas
> 3ft9 Ltd
> http://3ft9.com/
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Shiplu.Mokadd.im
ImgSign.com | A dynamic signature machine
Innovation distinguishes between follower and leader

--- End Message ---

Reply via email to