php-general Digest 10 Oct 2009 09:49:36 -0000 Issue 6383
Topics (messages 298818 through 298828):
Re: Fatal error on functions valid for PHP 4, 5
298818 by: Al
298821 by: Chris Streatfield
298823 by: kronos.aolohr.com
298824 by: Shawn McKenzie
Re: Newbie: Array of objects iteration
298819 by: MEM
298820 by: MEM
298825 by: Tommy Pham
298828 by: MEM
Re: Newb question about getting keys/values from a single array element
298822 by: Daevid Vincent
Re: Fatal error on functions valid for PHP 4, 5 [RESOLVED]
298826 by: kronos.aolohr.com
COM Help (hopefully)
298827 by: Adam Randall
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 ---
[email protected] wrote:
Hi,
Would someone be kind enough to test whether these following functions work?
I'm getting: "PHP Fatal error: Call to undefined function easter_date() . . .
easter_days" on both local and production sites.
<?php
echo easter_days(2009);
print "<br><br>";
echo date("M-d-Y", easter_date(2009));
print "<br><br>";
echo date("D d M Y", easter_date(2009));
?>
I'm using 5.2.10 production; PHP 5.2.4 local.
Tia,
Andre
Run get_defined_functions ( void )
--- End Message ---
--- Begin Message ---
Out put on PHP 5.2.4
<quote>
Parse error: syntax error, unexpected T_STRING in /testphp.php on line 2
</quote>
Line 2 is the first line of code.
Output on PHP 5.2.6 and on PHP 5.3.0 local
blank page.
All the best
Chris Streatfield
Tel: +64 4 475 7846
Mob: 021 102 6018
Skype: chrisstreat
On Sat, 10 Oct 2009 02:01:24 [email protected] wrote:
> Hi,
>
> Would someone be kind enough to test whether these following functions work?
>
> I'm getting: "PHP Fatal error: Call to undefined function
easter_date() . . .
> easter_days" on both local and production sites.
>
>
> <?php
>
> echo easter_days(2009);
> print "<br><br>";
> echo date("M-d-Y", easter_date(2009));
> print "<br><br>";
> echo date("D d M Y", easter_date(2009));
>
> ?>
>
>
> I'm using 5.2.10 production; PHP 5.2.4 local.
>
> Tia,
> Andre
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--- End Message ---
--- Begin Message ---
Thanks Chris.
Seems like the function is a dud. I have '-enable-calendar' working on both
local and production. Sigh . .
I have been using another modified 'easter' function, 'pFeast', (can't for the
life of me find it on the net now). It works well, but I need to set the
output to a variable, so I can use it for other purposes. But that's another
prob . . .
Regards,
Andree
On October 9, 2009 02:46:52 pm Chris Streatfield wrote:
> Out put on PHP 5.2.4
>
> <quote>
> Parse error: syntax error, unexpected T_STRING in /testphp.php on line 2
> </quote>
>
> Line 2 is the first line of code.
>
> Output on PHP 5.2.6 and on PHP 5.3.0 local
>
> blank page.
>
> All the best
> Chris Streatfield
> Tel: +64 4 475 7846
> Mob: 021 102 6018
> Skype: chrisstreat
>
> On Sat, 10 Oct 2009 02:01:24 [email protected] wrote:
> > Hi,
> >
> > Would someone be kind enough to test whether these following functions
> > work?
> >
> > I'm getting: "PHP Fatal error: Call to undefined function
>
> easter_date() . . .
>
> > easter_days" on both local and production sites.
> >
> >
> > <?php
> >
> > echo easter_days(2009);
> > print "<br><br>";
> > echo date("M-d-Y", easter_date(2009));
> > print "<br><br>";
> > echo date("D d M Y", easter_date(2009));
> >
> > ?>
> >
> >
> > I'm using 5.2.10 production; PHP 5.2.4 local.
> >
> > Tia,
> > Andre
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
[email protected] wrote:
> Thanks Chris.
>
> Seems like the function is a dud. I have '-enable-calendar' working on both
> local and production. Sigh . .
>
> I have been using another modified 'easter' function, 'pFeast', (can't for
> the
> life of me find it on the net now). It works well, but I need to set the
> output to a variable, so I can use it for other purposes. But that's another
> prob . . .
>
> Regards,
> Andree
>
>
>
> On October 9, 2009 02:46:52 pm Chris Streatfield wrote:
>> Out put on PHP 5.2.4
>>
>> <quote>
>> Parse error: syntax error, unexpected T_STRING in /testphp.php on line 2
>> </quote>
>>
>> Line 2 is the first line of code.
>>
>> Output on PHP 5.2.6 and on PHP 5.3.0 local
>>
>> blank page.
>>
>> All the best
>> Chris Streatfield
>> Tel: +64 4 475 7846
>> Mob: 021 102 6018
>> Skype: chrisstreat
>>
>> On Sat, 10 Oct 2009 02:01:24 [email protected] wrote:
>>> Hi,
>>>
>>> Would someone be kind enough to test whether these following functions
>>> work?
>>>
>>> I'm getting: "PHP Fatal error: Call to undefined function
>> easter_date() . . .
>>
>>> easter_days" on both local and production sites.
>>>
>>>
>>> <?php
>>>
>>> echo easter_days(2009);
>>> print "<br><br>";
>>> echo date("M-d-Y", easter_date(2009));
>>> print "<br><br>";
>>> echo date("D d M Y", easter_date(2009));
>>>
>>> ?>
>>>
>>>
>>> I'm using 5.2.10 production; PHP 5.2.4 local.
>>>
>>> Tia,
>>> Andre
>>>
>>> --
>>> PHP General Mailing List (http://www.php.net/)
>>> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
Well, I'm not sure why you don't have the function, but if you scroll to
the bottom of http://us2.php.net/manual/en/function.easter-date.php:
if(!function_exists('easter_date')) {
function easter_date ($Year)
{
/*
G is the Golden Number-1
H is 23-Epact (modulo 30)
I is the number of days from 21 March to the Paschal full moon
J is the weekday for the Paschal full moon (0=Sunday,
1=Monday, etc.)
L is the number of days from 21 March to the Sunday on or before
the Paschal full moon (a number between -6 and 28)
*/
$G = $Year % 19;
$C = (int)($Year / 100);
$H = (int)($C - (int)($C / 4) - (int)((8*$C+13) / 25) + 19*$G +
15) % 30;
$I = (int)$H - (int)($H / 28)*(1 - (int)($H / 28)*(int)(29 /
($H +
1))*((int)(21 - $G) / 11));
$J = ($Year + (int)($Year/4) + $I + 2 - $C + (int)($C/4)) % 7;
$L = $I - $J;
$m = 3 + (int)(($L + 40) / 44);
$d = $L + 28 - 31 * ((int)($m / 4));
$y = $Year;
$E = mktime(0,0,0, $m, $d, $y);
return $E;
}
}
--
Thanks!
-Shawn
http://www.spidean.com
--- End Message ---
--- Begin Message ---
Dear all, it's done.
Can I call your help for the remain issues please, I'm sure they are easy to
explain, and at some extend, common:
http://pastebin.com/m691d3e66
Instead of saving to the database, if I do a print_r or a var_dump, I get
the charsets quite ok.
However, they do not appear properly in the xls file.
I've tried to use utf8_encode but I was not sure where to apply it, and I
end up with the same strange chars on the .xls file.
If I write a <meta tag containing charset information on the script that
generates the file, I get headers already send message.
I've tried to add Content-type: application/x-msdownload; *charset=UTF-8;*
but no success either...
Would a proper use of utf8_encode solve this? If so, where?
Thanks in advance,
M.
--- End Message ---
--- Begin Message ---
Done.
print utf8_decode($xls_file);
Regards,
Márcio
> -----Original Message-----
> From: MEM [mailto:[email protected]]
> Sent: sexta-feira, 9 de Outubro de 2009 18:19
> To: 'MEM'; 'Fernando Castillo Aparicio'; 'Lester Caine'; 'php-
> [email protected]'
> Subject: RE: [PHP] Newbie: Array of objects iteration
>
> Dear all, it's done.
>
> Can I call your help for the remain issues please, I'm sure they are
> easy to explain, and at some extend, common:
>
> http://pastebin.com/m691d3e66
>
> Instead of saving to the database, if I do a print_r or a var_dump, I
> get the charsets quite ok.
> However, they do not appear properly in the xls file.
>
> I've tried to use utf8_encode but I was not sure where to apply it, and
> I end up with the same strange chars on the .xls file.
>
> If I write a <meta tag containing charset information on the script
> that generates the file, I get headers already send message.
>
> I've tried to add Content-type: application/x-msdownload; *charset=UTF-
> 8;* but no success either...
>
>
>
> Would a proper use of utf8_encode solve this? If so, where?
>
>
>
> Thanks in advance,
> M.
--- End Message ---
--- Begin Message ---
----- Original Message ----
> From: MEM <[email protected]>
> To: MEM <[email protected]>; Fernando Castillo Aparicio <[email protected]>;
> Lester Caine <[email protected]>; [email protected]
> Sent: Fri, October 9, 2009 6:22:05 AM
> Subject: RE: [PHP] Newbie: Array of objects iteration
>
> > Right now, I have something like this:
> >
> > foreach ($objRecord as $record)
> > {
> > //we will have a new line.
> > $xls_file .="\n";
> >
> >
> > foreach ($record as $column=>$value)
> > {
> > $xls_file .= $value."\t";
> > }
> >
> > }
> >
> > The only thing I need now, is to put on top, the column names, and I
> > have myself a xls file. YUpii!!
> >
> > I just need the column names... I will take a look on those functions
> > you have mentioned.
> >
> > Thanks a lot, :)
> > Márcio
>
>
> Update:
>
> "PDO::FETCH_OBJ
> Returns an anonymous object with property names that correspond to the
> column names returned in your result set."
>
> I will give a shot on array_keys however, is there any method to access the
> PROPERTIES NAMES of a given object?
>
MEM,
http://www.php.net/language.oop5.reflection
Regards,
Tommy
>
> Regards,
> M.
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
>
> MEM,
>
> http://www.php.net/language.oop5.reflection
>
>
> Regards,
> Tommy
>
>
And brand new world opens in from of my eyes... O.O.
I will search more info on this on the net... just for the records, as
properties names is concern, I couldn't find any better I suppose:
http://pt.php.net/manual/en/reflectionproperty.getname.php
I'm just wondering, we call it like this?
$property = new ReflectionProperty($myproperty);
$proptertyName = $property->getName();
Can we called statically like this?
$propertyName = ReflectionProperty::getName($myproperty); -> this would
be nice. :)
The documentation is a little bit lacking, and I'm a little bit newbie, is
this correct?
Note:
The array_keys as a possibility to retrieve ALL keys from a given array. It
would be nice to retrieve ALL properties names at once as well...
:)
Regards,
Márcio
--- End Message ---
--- Begin Message ---
> -----Original Message-----
> From: Shawn McKenzie [mailto:[email protected]]
> Sent: Friday, October 09, 2009 5:32 AM
> To: Daevid Vincent
> Cc: [email protected]
> Subject: Re: Newb question about getting keys/values from a
> single array element
>
> Daevid Vincent wrote:
> > I feel like a total newb asking this, but I'm just having a
> brain fart or
> > something...
> >
> > I'm writing a page where I can either get back a list of items:
> >
> > Array {
> > [1233] => "apple",
> > [6342] => "apricot",
> > [2345] => "banana",
> > ...
> > }
> >
> > where the user then refines it by choosing one single item
> and a single
> > element array is returned like this:
> >
> > Array {
> > [8575] => "peach",
> > }
> >
> > How can I get this $item so I can print it like so:
> >
> > echo "The ID is $id and the name is $name";
> >
> > Normally with an array of items, I do a:
> >
> > foreach ($item as $id => $name) echo...
> >
> > But that seems overkill for this scenario.
> >
> > The rub is that I don't know the "id", so I can't use
> $item[0], and I also
> > don't have something like $item['name'] to use either.
> >
> > There's got to be an easy way to extract those.
> >
> > list($id, $name) = $operator;
> >
> > Felt like it would work for a minute (wishful thinking).
> >
> >
> > (I'm too embarrased to even sign my name on this one)
> >
>
> $a = array(8575 => 'peach');
>
> $key = key($a);
> $value = current($a);
BRILLIANT! That's EXACTLY what I was looking for!
--- End Message ---
--- Begin Message ---
On October 9, 2009 05:17:18 pm you wrote:
> [email protected] wrote:
> > Thanks Chris.
> >
> > Seems like the function is a dud. I have '-enable-calendar' working on
> > both local and production. Sigh . .
> >
> > I have been using another modified 'easter' function, 'pFeast', (can't
> > for the life of me find it on the net now). It works well, but I need to
> > set the output to a variable, so I can use it for other purposes. But
> > that's another prob . . .
> >
> > Regards,
> > Andree
> >
> > On October 9, 2009 02:46:52 pm Chris Streatfield wrote:
> >> Out put on PHP 5.2.4
> >>
> >> <quote>
> >> Parse error: syntax error, unexpected T_STRING in /testphp.php on line 2
> >> </quote>
> >>
> >> Line 2 is the first line of code.
> >>
> >> Output on PHP 5.2.6 and on PHP 5.3.0 local
> >>
> >> blank page.
> >>
> >> All the best
> >> Chris Streatfield
> >> Tel: +64 4 475 7846
> >> Mob: 021 102 6018
> >> Skype: chrisstreat
> >>
> >> On Sat, 10 Oct 2009 02:01:24 [email protected] wrote:
> >>> Hi,
> >>>
> >>> Would someone be kind enough to test whether these following functions
> >>> work?
> >>>
> >>> I'm getting: "PHP Fatal error: Call to undefined function
> >>
> >> easter_date() . . .
> >>
> >>> easter_days" on both local and production sites.
> >>>
> >>>
> >>> <?php
> >>>
> >>> echo easter_days(2009);
> >>> print "<br><br>";
> >>> echo date("M-d-Y", easter_date(2009));
> >>> print "<br><br>";
> >>> echo date("D d M Y", easter_date(2009));
> >>>
> >>> ?>
> >>>
> >>>
> >>> I'm using 5.2.10 production; PHP 5.2.4 local.
> >>>
> >>> Tia,
> >>> Andre
> >>>
> >>> --
> >>> PHP General Mailing List (http://www.php.net/)
> >>> To unsubscribe, visit: http://www.php.net/unsub.php
>
> Well, I'm not sure why you don't have the function, but if you scroll to
> the bottom of http://us2.php.net/manual/en/function.easter-date.php:
>
> if(!function_exists('easter_date')) {
> function easter_date ($Year)
> {
> /*
> G is the Golden Number-1
> H is 23-Epact (modulo 30)
> I is the number of days from 21 March to the Paschal full moon
> J is the weekday for the Paschal full moon (0=Sunday,
> 1=Monday, etc.)
> L is the number of days from 21 March to the Sunday on or before
> the Paschal full moon (a number between -6 and 28)
> */
> $G = $Year % 19;
> $C = (int)($Year / 100);
> $H = (int)($C - (int)($C / 4) - (int)((8*$C+13) / 25) + 19*$G +
> 15) % 30;
> $I = (int)$H - (int)($H / 28)*(1 - (int)($H / 28)*(int)(29 /
> ($H +
> 1))*((int)(21 - $G) / 11));
> $J = ($Year + (int)($Year/4) + $I + 2 - $C + (int)($C/4)) % 7;
> $L = $I - $J;
> $m = 3 + (int)(($L + 40) / 44);
> $d = $L + 28 - 31 * ((int)($m / 4));
> $y = $Year;
> $E = mktime(0,0,0, $m, $d, $y);
>
> return $E;
> }
> }
Thanks Shawn!
Actually, I've given up on the PHP function, and managed to extract the info I
need from 'pFeast' class. This class uses the same code as above but with
some major enhancements.
A little bit more work on the code, and it'll be accomplishing what I need.
Thanks for your suggestion!
Regards,
Andre
--- End Message ---
--- Begin Message ---
We have a US postal database called ZP4 that we that we use to scrub
client addresses into something useful. For future projects we need to
expand on this scrubbing so that we can view counties and such. The
scrubbing is currently being performed by a custom application a
former employee wrote for us while he still worked here.
Unfortunately, he didn't commit the source of that application into
our SVN repository (bad). Sadly, I don't have C/C++ creation skills
worth relying upon.
What I found in ZP4 is a COM wrapper for the ZP4 DLL. From the
examples it should be simple to implement what I want, and this VB
code does work fine:
--- begin ---
Set ZP4 = CreateObject("zp4ipcom.zp4com")
ZP4.reset
ZP4.input "Address", "2401 Utah avenue south"
ZP4.input "City", "seattle"
ZP4.input "State", "wa"
ZP4.input "ZIP", "98134"
ZP4.correct
WScript.Echo ZP4.output("Error code")
WScript.Echo ZP4.output("Address (final)")
WScript.Echo ZP4.output("City (final)")
WScript.Echo ZP4.output("State (final)")
WScript.Echo ZP4.output("ZIP (five-digit)")
WScript.Echo ZP4.output("County name")
--- end ---
However, when I implement this code in PHP using COM all I get are errors:
<?php
try
{
$zp4 = new com( 'zp4ipcom.zp4com' );
$zp4->reset();
$zp4->input( 'Address', '2401 Utah avenue south' );
$zp4->input( 'City', 'seattle' );
$zp4->input( 'State', 'wa' );
$zp4->input( 'ZIP', '98134' );
$zp4->correct();
echo( $zp4->output( 'Error code' ) . "\n" );
echo( $zp4->output( 'Address (final)' ) . "\n" );
echo( $zp4->output( 'City (final)' ) . "\n" );
echo( $zp4->output( 'State (final)' ) . "\n" );
echo( $zp4->output( 'ZIP (five-digit)' ) . "\n" );
echo( $zp4->output( 'County name' ) . "\n" );
}
catch( exception $e )
{
echo( $e . "\n" );
}
?>
Results:
exception 'com_exception' with message 'Error [0x80020003] Member not found.
' in C:\Documents and Settings\adamr\Desktop\zp4.com.php:7
Stack trace:
#0 C:\Documents and Settings\adamr\Desktop\zp4.com.php(7): com->reset()
#1 {main}
I've tried everything I could think to get the above to work. If I
specify a member that I know is not in the ZP4 DLL I get a different
error. The "Member not found" error always seems to line up with the
procedures/functions defined in the ZP4IPCOM source.
ZP4 is a Windows only application. My development machine is running
PHP 5.2.6. I've done other COM related code with Word without any
troubles. I'm guessing that maybe the ZP4IPCOM interface itself is not
complete enough for PHP, or there is some bug that I'm missing. The
source for the ZP4IPCOM is provided with the ZP4 disk, but it's all in
Pascal and I'm not sure hot to either tweak or rebuild that (my VS
2005 doesn't seem to think much of it :)
While I could go with a VB solution for doing the address scrubbing, I
had wanted to set it up in PHP so that I could open one COM connection
to the DLL, and then via database burn through a large number of
addresses. If I had the skills I'd also rather just create an
extension for PHP itself that is a wrapper for the ZP4 DLL. If someone
is interested in building that for my company on commission I'd love
to discuss that with you.
If anyone wants to help me with this I'd greatly appreciate it.
Regards,
Adam.
--
Adam Randall
http://www.xaren.net
AIM: blitz574
--- End Message ---