php-general Digest 4 Dec 2008 19:49:16 -0000 Issue 5826

Topics (messages 284081 through 284111):

Does php 5.2.5 support imap4rev1 search criterias
        284081 by: Ergün Koray
        284082 by: Richard Heyes
        284085 by: Ergün Koray
        284087 by: Richard Heyes

PHP - Jasper Report Integeration
        284083 by: Johny John

IE8 and HTML5
        284084 by: Richard Heyes
        284086 by: Sancar Saran
        284090 by: Bastien Koert
        284091 by: Richard Heyes
        284092 by: Bastien Koert
        284104 by: Jay Moore
        284105 by: Bastien Koert
        284106 by: Jay Moore
        284107 by: Richard Heyes
        284108 by: Boyd, Todd M.
        284109 by: Richard Heyes

imagecreatefromgif & imagecolortransparent() ??
        284088 by: LucaP
        284101 by: Ólafur Waage

Last working day of a month
        284089 by: Angelo Zanetti
        284093 by: Andrew Ballard
        284096 by: Boyd, Todd M.
        284097 by: Jochem Maas
        284099 by: Govinda

How to fetch .DOC or .DOCX file in php
        284094 by: Jagdeep Singh
        284095 by: Boyd, Todd M.
        284110 by: Jim Lucas

Using DateTimeZone
        284098 by: Lester Caine
        284100 by: Lester Caine
        284103 by: Lester Caine

COM and the PHP equivalent of ASP Currency data type
        284102 by: Alex Bovey

Help with IF ELSE
        284111 by: David Stoltz

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 ---
I have php 5.2.5 installed on fedora 9. I have written a little php
program that uses the search criteria SENTSINCE. But it complains with
:
Unknown search criterion: SENTSINCE


Can anbody help ?

-- 
Ergün Koray
bb, vm, mu, xg

--- End Message ---
--- Begin Message ---
> I have php 5.2.5 installed on fedora 9. I have written a little php
> program that uses the search criteria SENTSINCE. But it complains with
> :
> Unknown search criterion: SENTSINCE

It doesn't appear to be a valid search option - only SINCE is listed here:

http://uk2.php.net/manual/en/function.imap-search.php

-- 
Richard Heyes

HTML5 Graphing for FF, Chrome, Opera and Safari:
http://www.rgraph.org (Updated November 29th)

--- End Message ---
--- Begin Message ---
Thank you. Will this be implemented or should I get in touch with the
developers of the c-client libraries ?

Our mail server is Lotus Domino 7 and the problem with this server is
that it does not get correct results from the SINCE query. It
understands the SENTSINCE  query correct.


On Thu, Dec 4, 2008 at 10:30 AM, Richard Heyes <[EMAIL PROTECTED]> wrote:
>> I have php 5.2.5 installed on fedora 9. I have written a little php
>> program that uses the search criteria SENTSINCE. But it complains with
>> :
>> Unknown search criterion: SENTSINCE
>
> It doesn't appear to be a valid search option - only SINCE is listed here:
>
> http://uk2.php.net/manual/en/function.imap-search.php
>
> --
> Richard Heyes
>
> HTML5 Graphing for FF, Chrome, Opera and Safari:
> http://www.rgraph.org (Updated November 29th)
>



-- 
Ergün Koray
bb, vm, mu, xg

--- End Message ---
--- Begin Message ---
> Thank you. Will this be implemented or should I get in touch with the
> developers of the c-client libraries ?
>
> Our mail server is Lotus Domino 7 and the problem with this server is
> that it does not get correct results from the SINCE query. It
> understands the SENTSINCE  query correct.

No idea. Can you fake it? ie get all the message numbers, remove the
ones that result from a BEFORE search.

-- 
Richard Heyes

HTML5 Graphing for FF, Chrome, Opera and Safari:
http://www.rgraph.org (Updated November 29th)

--- End Message ---
--- Begin Message ---
Dear All,
Do any one know how to integrate PHP with Jasper Reports. I tried it..but
its says "Unable to create Java Virtual Machine "
Please refer this link for more details.
http://jagadmaya.com/integration-phpjasperreports.html

Regards,
Johny
www.phpshore.com

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

>From a recent IEBlog post:

http://blogs.msdn.com/ie/archive/2008/12/03/compatibility-view-improvements-to-come-in-ie8.aspx

> ...and our start on HTML5 support.

Does this mean canvas support? Is it as a direct result of Chrome
being released and MS realising (finally) they are going to have to
remain competitive? Wouldn't that be nice?

-- 
Richard Heyes

HTML5 Graphing for FF, Chrome, Opera and Safari:
http://www.rgraph.org (Updated November 29th)

--- End Message ---
--- Begin Message ---
On Thursday 04 December 2008 10:45:21 Richard Heyes wrote:
> Hi,
>
> From a recent IEBlog post:
>
> http://blogs.msdn.com/ie/archive/2008/12/03/compatibility-view-improvements
>-to-come-in-ie8.aspx
>
Microsoft and Standarts ?

Ship load of crap...

Every web developer should open class action suit against M$ because of IE and 
M$ should banned from to create web browser for ever...


--- End Message ---
--- Begin Message ---
On Thu, Dec 4, 2008 at 4:44 AM, Sancar Saran <[EMAIL PROTECTED]>wrote:

> On Thursday 04 December 2008 10:45:21 Richard Heyes wrote:
> > Hi,
> >
> > From a recent IEBlog post:
> >
> >
> http://blogs.msdn.com/ie/archive/2008/12/03/compatibility-view-improvements
> >-to-come-in-ie8.aspx
> >
> Microsoft and Standarts ?
>
> Ship load of crap...
>
> Every web developer should open class action suit against M$ because of IE
> and
> M$ should banned from to create web browser for ever...
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
I am running IE8 beta and its a PoS. Constantly crashing and flaky as shit.

-- 

Bastien

Cat, the other other white meat

--- End Message ---
--- Begin Message ---
> I am running IE8 beta and its a PoS. Constantly crashing and flaky as shit.

Point of Sale...?

-- 
Richard Heyes

HTML5 Graphing for FF, Chrome, Opera and Safari:
http://www.rgraph.org (Updated November 29th)

--- End Message ---
--- Begin Message ---
On Thu, Dec 4, 2008 at 9:10 AM, Richard Heyes <[EMAIL PROTECTED]> wrote:

> > I am running IE8 beta and its a PoS. Constantly crashing and flaky as
> shit.
>
> Point of Sale...?
>
> --
> Richard Heyes
>
> HTML5 Graphing for FF, Chrome, Opera and Safari:
> http://www.rgraph.org (Updated November 29th)
>

haha

-- 

Bastien

Cat, the other other white meat

--- End Message ---
--- Begin Message ---
I am running IE8 beta and its a PoS. Constantly crashing and flaky as shit.


<Devil's Advocate>
It's a beta.  What do you expect?
</Devil's Advocate>

--- End Message ---
--- Begin Message ---
On Thu, Dec 4, 2008 at 11:57 AM, Jay Moore <[EMAIL PROTECTED]> wrote:

> I am running IE8 beta and its a PoS. Constantly crashing and flaky as shit.
>>
>>
> <Devil's Advocate>
> It's a beta.  What do you expect?
> </Devil's Advocate>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
How about not throwing a js error on opening a new tab? Kinda basic, even MS
should be able to handle that or so I would have hoped. I have less issues
with Chrome and its beta

-- 

Bastien

Cat, the other other white meat

--- End Message ---
--- Begin Message ---
Bastien Koert wrote:
On Thu, Dec 4, 2008 at 11:57 AM, Jay Moore <[EMAIL PROTECTED]> wrote:

I am running IE8 beta and its a PoS. Constantly crashing and flaky as shit.

<Devil's Advocate>
It's a beta.  What do you expect?
</Devil's Advocate>

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


How about not throwing a js error on opening a new tab? Kinda basic, even MS
should be able to handle that or so I would have hoped. I have less issues
with Chrome and its beta


At least have the decency to wait till it's out of beta to complain about all the issues that should have been fixed in the beta.

Don't worry.  They'll still be there.

;)

--- End Message ---
--- Begin Message ---
> I have less issues
> with Chrome and its beta

Not thrashing my HDD is also kinda basic, but Chrome 0.2 was more than
happy to do that.

-- 
Richard Heyes

HTML5 Graphing for FF, Chrome, Opera and Safari:
http://www.rgraph.org (Updated November 29th)

--- End Message ---
--- Begin Message ---
> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
> Behalf Of Richard Heyes
> Sent: Thursday, December 04, 2008 11:10 AM
> To: Bastien Koert
> Cc: Jay Moore; [EMAIL PROTECTED]
> Subject: Re: [PHP] IE8 and HTML5
> 
> > I have less issues
> > with Chrome and its beta
> 
> Not thrashing my HDD is also kinda basic, but Chrome 0.2 was more than
> happy to do that.

http://www.srware.net/en/software_srware_iron.php

Iron: Chromium source re-worked for efficiency and privacy. Not sure if
it will solve your thrashing issue, but then again... I'm not sure how
or why a browser would cause your HDD to thrash in the first place. Got
a lot of questionable videos open in several tabs, eh? ;) I've had
Firefox thrash sometimes when it's loading lots of Applets and Flash
objects, etc., though, so I guess I can understand.

(And don't get me wrong--I had tons of problems with Chrome; mostly
about crashing unexpectedly.)


// Todd

--- End Message ---
--- Begin Message ---
> (And don't get me wrong--I had tons of problems with Chrome; mostly
> about crashing unexpectedly.)

That was the only one for me, and it doesn't do it anymore. Guess it
was an update to 0.4 (?) that fixed it. Switching to FF fixed it quite
well... Thing is, it's a beater - until it gets close to a 1 version,
I'm not going to worry about it.

-- 
Richard Heyes

HTML5 Graphing for FF, Chrome, Opera and Safari:
http://www.rgraph.org (Updated November 29th)

--- End Message ---
--- Begin Message ---
Hi all, the simple code snippet:

header('Content-type: image/gif');
$im = imagecreatefromgif("/path/Mypic.gif");
$background = imagecolorallocate($im, 255, 255, 255);
imagecolortransparent($im,$background);

imagegif($im,'/path/TransparentPic.gif');
imagedestroy($im);


is creating the new image but is not setting the white background to
transparent;
I am sure about the presence of the white color in the background
(checked it with imagecolorat() etc).

a similarly simple test setting transparency on a new image created
with 'imagecreatetruecolor()' works correctly... any hints?!

Cheers, Luca

--- End Message ---
--- Begin Message ---
Here's a code snippet from the php.net documentation on
imagecolortransparent by Blaine Ehrhart

<?php
    $im = imagecreatefromgif('trans.gif');
    $img = imagecreatetruecolor(16,16);
    $trans = imagecolorallocate($img,255,99,140);
    imagecolortransparent($img,$trans);
    imagecopy($img,$im,0,0,0,0,16,16);
    imagetruecolortopalette($img, true, 256);
    imageinterlace($img);
    imagegif($img,'trans.gif');
    imagedestroy($img);
?>

See if it works.

On Thu, Dec 4, 2008 at 10:44 AM, LucaP <[EMAIL PROTECTED]> wrote:
>
> Hi all, the simple code snippet:
>
> header('Content-type: image/gif');
> $im = imagecreatefromgif("/path/Mypic.gif");
> $background = imagecolorallocate($im, 255, 255, 255);
> imagecolortransparent($im,$background);
>
> imagegif($im,'/path/TransparentPic.gif');
> imagedestroy($im);
>
>
> is creating the new image but is not setting the white background to
> transparent;
> I am sure about the presence of the white color in the background
> (checked it with imagecolorat() etc).
>
> a similarly simple test setting transparency on a new image created
> with 'imagecreatetruecolor()' works correctly... any hints?!
>
> Cheers, Luca
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

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

I am busy trying to figure out how to get the last working day in a month.

I was wondering if there was a script already written, but this is what I
imagine should work:

Get the current day and see if it's the last day of the month. If its true
check if it's a Saturday or Sunday if it's either of those 2 days then
return false else return true?

I also need to take public holidays into account. What would be the best
solution for that? Store the public holidays in a table and check if the
current day isn't a public holiday?

Any advice is appreciated. 

TIA
Angelo


Web: http://www.elemental.co.za 



--- End Message ---
--- Begin Message ---
On Thu, Dec 4, 2008 at 9:03 AM, Angelo Zanetti <[EMAIL PROTECTED]> wrote:
> Hi all,
>
> I am busy trying to figure out how to get the last working day in a month.
>
> I was wondering if there was a script already written, but this is what I
> imagine should work:
>
> Get the current day and see if it's the last day of the month. If its true
> check if it's a Saturday or Sunday if it's either of those 2 days then
> return false else return true?
>
> I also need to take public holidays into account. What would be the best
> solution for that? Store the public holidays in a table and check if the
> current day isn't a public holiday?
>
> Any advice is appreciated.
>
> TIA
> Angelo
>
>

If your application is already using a database, I would use a date
table rather than a holiday table. You can add columns to indicate
whether each date is a workday, weekday, weekend, holiday, or any
other date category/group that you need to track.

Andrew

--- End Message ---
--- Begin Message ---
> -----Original Message-----
> From: Andrew Ballard [mailto:[EMAIL PROTECTED]
> Sent: Thursday, December 04, 2008 8:32 AM
> To: Angelo Zanetti
> Cc: [EMAIL PROTECTED]
> Subject: Re: [PHP] Last working day of a month
> Importance: Low
> 
> On Thu, Dec 4, 2008 at 9:03 AM, Angelo Zanetti <[EMAIL PROTECTED]>
> wrote:
> > Hi all,
> >
> > I am busy trying to figure out how to get the last working day in a
> month.
> >
> > I was wondering if there was a script already written, but this is
> what I
> > imagine should work:
> >
> > Get the current day and see if it's the last day of the month. If its
> true
> > check if it's a Saturday or Sunday if it's either of those 2 days
> then
> > return false else return true?
> >
> > I also need to take public holidays into account. What would be the
> best
> > solution for that? Store the public holidays in a table and check if
> the
> > current day isn't a public holiday?
> >
> 
> If your application is already using a database, I would use a date
> table rather than a holiday table. You can add columns to indicate
> whether each date is a workday, weekday, weekend, holiday, or any
> other date category/group that you need to track.

That seems like a waste of space and database calls to me. (Yes, I know space 
is cheap... but it should at least be thought about briefly. Using that space 
costs cycles, etc.) Since the exceptions to his rule are so few in comparison 
to the days that follow, I think documenting the exceptions and assuming it's a 
workday if it's not an exception makes more sense (IMHO).

I'd probably store all holidays in a table and assume that Saturdays/Sundays 
are not workdays unless they have a corresponding entry in the same table that 
holds the holidays. Call the table "exceptions." The exception to a workday is 
a holiday. The exception to a weekend is a workday. :)

HTH,


// Todd

--- End Message ---
--- Begin Message ---
Angelo Zanetti schreef:
> Hi all, 
> 
> I am busy trying to figure out how to get the last working day in a month.
> 
> I was wondering if there was a script already written, but this is what I
> imagine should work:
> 
> Get the current day and see if it's the last day of the month. If its true
> check if it's a Saturday or Sunday if it's either of those 2 days then
> return false else return true?
> 
> I also need to take public holidays into account. What would be the best
> solution for that? Store the public holidays in a table and check if the
> current day isn't a public holiday?

you need a process with a few simple steps.

1. find the last day of the month, this is quite easy ... google gives answers
as does the manual. e.g.:

http://lutrov.com/blog/php-last-day-of-the-month-calculation/

2. determine if this is a week day. if yes go to step three else 'roll the date 
back'
24 hours and go to step 2.

3. determine if this is a holiday, if yes 'roll the date back' 24 hours and go
to step 2. else you have found the last working day of the month.

with regard to determining if a day is a holiday your best bet is to store these
in a database table. and check against that ... you may be able to find a source
of holiday data online from which you can sync your local datasource 
periodically
(e.g. via a cron job).

hth

> 
> Any advice is appreciated. 
> 
> TIA
> Angelo
> 
> 
> Web: http://www.elemental.co.za 
> 
> 
> 


--- End Message ---
--- Begin Message ---
you need a process with a few simple steps.

1. find the last day of the month, this is quite easy ... google gives answers
as does the manual. e.g.:

http://lutrov.com/blog/php-last-day-of-the-month-calculation/

2. determine if this is a week day. if yes go to step three else 'roll the date back'
24 hours and go to step 2.

3. determine if this is a holiday, if yes 'roll the date back' 24 hours and go
to step 2. else you have found the last working day of the month.

with regard to determining if a day is a holiday your best bet is to store these in a database table. and check against that ... you may be able to find a source of holiday data online from which you can sync your local datasource periodically
(e.g. via a cron job).

hth

Well it should!! The advice I love most of all is like this, helping me see the clear logic, and then letting me figure out how to write it w/the language at hand. This reply post of mine does not add anything for anyone; sometimes I just can't help express my appreciation for things. Brilliant Jochem!
-G

--- End Message ---
--- Begin Message ---
Hi !

I want to fetch text from .doc / .docx file and save it into database file.
But when  I tried to fetch text with fopen/fgets etc ... It gave me special
characters with text.

(With .txt files everything is fine)
Only problem is with doc/docx files.
I dont know whow to remove "SPECIAL CHARACTERS" from this text ...

Regards

Jagdeep Singh
India
9988009272

--- End Message ---
--- Begin Message ---
> -----Original Message-----
> From: Jagdeep Singh [mailto:[EMAIL PROTECTED]
> Sent: Thursday, December 04, 2008 8:39 AM
> To: [EMAIL PROTECTED]
> Subject: [PHP] How to fetch .DOC or .DOCX file in php
> Importance: Low
> 
> Hi !
> 
> I want to fetch text from .doc / .docx file and save it into database
> file.
> But when  I tried to fetch text with fopen/fgets etc ... It gave me
> special
> characters with text.
> 
> (With .txt files everything is fine)
> Only problem is with doc/docx files.
> I dont know whow to remove "SPECIAL CHARACTERS" from this text ...

A.) This has been handled on this list several times. Please search the
archives before posting a question.
B.) Did you even TRY to Google for this? In the first 5 matches for "php
open ms word" I found this:

http://www.developertutorials.com/blog/php/extracting-text-from-word-doc
uments-via-php-and-com-81/

You will need an MS Windows machine for this solution to work. If you're
using *nix... well... good luck.


// Todd

--- End Message ---
--- Begin Message ---
Boyd, Todd M. wrote:
>> -----Original Message-----
>> From: Jagdeep Singh [mailto:[EMAIL PROTECTED]
>> Sent: Thursday, December 04, 2008 8:39 AM
>> To: [EMAIL PROTECTED]
>> Subject: [PHP] How to fetch .DOC or .DOCX file in php
>> Importance: Low
>>
>> Hi !
>>
>> I want to fetch text from .doc / .docx file and save it into database
>> file.
>> But when  I tried to fetch text with fopen/fgets etc ... It gave me
>> special
>> characters with text.
>>
>> (With .txt files everything is fine)
>> Only problem is with doc/docx files.
>> I dont know whow to remove "SPECIAL CHARACTERS" from this text ...
> 
> A.) This has been handled on this list several times. Please search the
> archives before posting a question.
> B.) Did you even TRY to Google for this? In the first 5 matches for "php
> open ms word" I found this:
> 
> http://www.developertutorials.com/blog/php/extracting-text-from-word-doc
> uments-via-php-and-com-81/
> 
> You will need an MS Windows machine for this solution to work. If you're
> using *nix... well... good luck.
> 
> 
> // Todd
> 

Ah, not true about the MS requirement.  If all you want is the clear/clean
text (without any formatting), then I can do it with php on any platform.

If this is what is needed, here is the code to do it.

<?php

$filename = './12345.doc';
if ( file_exists($filename) ) {

        if ( ($fh = fopen($filename, 'r')) !== false ) {

                $headers = fread($fh, 0xA00);

                # 1 = (ord(n)*1) ; Document has from 0 to 255 characters
                $n1 =     ( ord($headers[0x21C]) - 1 );

                # 1 = ((ord(n)-8)*256) ; Document has from 256 to 63743 
characters
                $n2 =   ( ( ord($headers[0x21D]) - 8 ) * 256 );

                # 1 = ((ord(n)*256)*256) ; Document has from 63744 to 16775423 
characters
                $n3 =   ( ( ord($headers[0x21E]) * 256 ) * 256 );

                # (((ord(n)*256)*256)*256) ; Document has from 16775424 to 
4294965504 characters
                $n4 = ( ( ( ord($headers[0x21F]) * 256 ) * 256 ) * 256 );

                # Total length of text in the document
                $textLength = ($n1 + $n2 + $n3 + $n4);
                
                $extracted_plaintext = fread($fh, $textLength);
                
                # if you want the plain text with no formatting, do this
                echo $extracted_plaintext;
                
                # if you want to see your paragraphs in a web page, do this
                echo nl2br($extracted_plaintext);

        }

}

?>

Hope this helps.

I am working on a set of php classes that will be able to read the text with 
the formatting included and convert it to a standard document format.
The standard format that it will end up in has yet

-- 
Jim Lucas

   "Some men are born to greatness, some achieve greatness,
       and some have greatness thrust upon them."

Twelfth Night, Act II, Scene V
    by William Shakespeare

--- End Message ---
--- Begin Message --- I'm looking to tidy up things a bit by clearing out a lot of old code and switching to using the internal DateTime functions.

Information is stored in the databases UTC normalized, and we get around the problem of getting a real tz offset by getting the users to register it rather than simply relying on the browser. So dates and times are displayed either UTC or user local time. The server defaults are not relevant, as only the user details should be used.

The thing that I am having a little trouble establishing is the correct way to take a UTC unix epoch timestamp from the data and display it with the users timezone offset.

$dateTimeZoneUser = new DateTimeZone("user's setting");
$dateTimeUser =
new DateTime( date( "U", $datetime_to_display ), $dateTimeZoneUser );
$date = $dateTimeUser->format( DATE_ATOM );

Is giving results wildly different from 2008
So how is one supposed to handle epoch values?

I little aside while sorting the lookup table for timezones, DateTimeZone::listIdentifiers() apparently should accept a country code, but again I can't seem to find out how to make it work. Would I expect it to return just values for the country requested?


Lester Caine - G8HFL
-----------------------------
Contact - http://lsces.co.uk/lsces/wiki/?page=contact
L.S.Caine Electronic Services - http://lsces.co.uk
EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk//
Firebird - http://www.firebirdsql.org/index.php

--- End Message ---
--- Begin Message ---
Lester Caine wrote:
I'm looking to tidy up things a bit by clearing out a lot of old code and switching to using the internal DateTime functions.

Information is stored in the databases UTC normalized, and we get around the problem of getting a real tz offset by getting the users to register it rather than simply relying on the browser. So dates and times are displayed either UTC or user local time. The server defaults are not relevant, as only the user details should be used.

OK cracked the first bit - need an '@' in place of the "U"

The thing that I am having a little trouble establishing is the correct way to take a UTC unix epoch timestamp from the data and display it with the users timezone offset.

$dateTimeZoneUser = new DateTimeZone("user's setting");
$dateTimeUser =
new DateTime( date( "U", $datetime_to_display ), $dateTimeZoneUser );
new DateTime( '@'.$datetime_to_display, $dateTimeZoneUser );
$date = $dateTimeUser->format( DATE_ATOM );

Is giving results wildly different from 2008
So how is one supposed to handle epoch values?
That gives me the correct date - but changing the timezone makes no difference to the output - seems to be displaying local timezone only.

I little aside while sorting the lookup table for timezones, DateTimeZone::listIdentifiers() apparently should accept a country code, but again I can't seem to find out how to make it work. Would I expect it to return just values for the country requested?

--
Lester Caine - G8HFL
-----------------------------
Contact - http://lsces.co.uk/lsces/wiki/?page=contact
L.S.Caine Electronic Services - http://lsces.co.uk
EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk//
Firebird - http://www.firebirdsql.org/index.php

--- End Message ---
--- Begin Message ---
Lester Caine wrote:
Lester Caine wrote:
I'm looking to tidy up things a bit by clearing out a lot of old code and switching to using the internal DateTime functions.

Information is stored in the databases UTC normalized, and we get around the problem of getting a real tz offset by getting the users to register it rather than simply relying on the browser. So dates and times are displayed either UTC or user local time. The server defaults are not relevant, as only the user details should be used.

OK cracked the first bit - need an '@' in place of the "U"

The thing that I am having a little trouble establishing is the correct way to take a UTC unix epoch timestamp from the data and display it with the users timezone offset.

$dateTimeZoneUser = new DateTimeZone("user's setting");
$dateTimeUser =
new DateTime( date( "U", $datetime_to_display ), $dateTimeZoneUser );
new DateTime( '@'.$datetime_to_display, $dateTimeZoneUser );
Completing the circle slowly ....
$dateTimeUser = new DateTime( '@'.$datetime_to_display);
$dateTimeUser->setTimeZone( $dateTimeZoneUser );

$date = $dateTimeUser->format( DATE_ATOM );

But of cause the bit of the jigsaw I forgot is that this needs translating to the correct language. format does not respect 'setlocale' setting? How do I get this translated to the users language as well as their timezone?

Is giving results wildly different from 2008
So how is one supposed to handle epoch values?
That gives me the correct date - but changing the timezone makes no difference to the output - seems to be displaying local timezone only.

I little aside while sorting the lookup table for timezones, DateTimeZone::listIdentifiers() apparently should accept a country code, but again I can't seem to find out how to make it work. Would I expect it to return just values for the country requested?

--
Lester Caine - G8HFL
-----------------------------
Contact - http://lsces.co.uk/lsces/wiki/?page=contact
L.S.Caine Electronic Services - http://lsces.co.uk
EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk//
Firebird - http://www.firebirdsql.org/index.php

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

I am working with a COM interface and the specification which is wrtten for
ASP calls for a "Currency" data type to be passed to a function.  What is
the equivalent in PHP?

If I call com_print_typeinfo() I can see that the function has the following
info:

    function GetPrice(
        /* VT_PTR [26] [in][out] --> VT_VARIANT [12]  */ &$Account,
        /* VT_PTR [26] [in][out] --> VT_CY [6]  */ &$Quant,
        /* VT_PTR [26] [in][out] --> VT_I2 [2]  */ &$QuantMult,
        /* VT_PTR [26] [in][out] --> VT_I2 [2]  */ &$prMult
        )

The parameter I am having problems with parameter 2 - $Quant.

I tried to create a VARIANT of type VT_CY so I did:

$qty = new VARIANT('1.0000', VT_CY);

The error I am getting is:

Uncaught exception 'com_exception' with message 'Parameter 2: Type mismatch.


Thanks all,

Alex

-

Alex Bovey
Web Developer | Alex Bovey Consultancy Ltd
Registered in England & Wales no. 6471391 | VAT no. 934 8959 65
PHP | MySQL | AJAX | XHTML | CSS | Javascript | XML | W3C Accessibility

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

I'm new to PHP - I'm trying to figure out what is wrong with a simple IF
ELSE block I have...if the recordset $rs is empty (login fails), the 1st
part of the block works, and redirects the user to default.php - but if
the login works, and $rs is not empty, the 2nd "else" part does not
work, and does not redirect to menu.php - I just get  a blank white
screen on the login.php page (where this code is)....

Any ideas? What is the proper way to detect an empty recordset?

Thanks!

Below is the code:
--------------------
...
$query = "SELECT user_id FROM users WHERE username = '$uname' AND
password = '$pword'";

$rs = $conn->execute($query);

if($rs->EOF)
{
        $rs->Close();
        $conn->Close();
        $rs = null;
        $conn = null;
        header("Location: default.php?err=Invalid%20Login%20Attempt");
        exit;
}
else
{
        $rs->Close();
        $conn->Close();
        $rs = null;
        $conn = null;
        header("Location: menu.php");
        exit;
}

--- End Message ---

Reply via email to