OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
 
php-general Digest 30 Jan 2007 14:16:58 -0000 Issue 4598

php-general-digest-helplists.php.net
Date: Tue Jan 30 2007 - 08:16:58 CST


php-general Digest 30 Jan 2007 14:16:58 -0000 Issue 4598

Topics (messages 247982 through 248021):

Re: Select record by ID
        247982 by: Roman Neuhauser
        247991 by: Richard Lynch
        247994 by: Larry Garfield
        248001 by: Richard Lynch

Re: Can a class instance a property of another class
        247983 by: Richard Lynch
        248015 by: Jochem Maas

Re: Creating an array as a property of an object
        247984 by: Richard Lynch

Re: What search algorithm does in_array() use?
        247985 by: Robert Cummings
        247988 by: Richard Lynch
        247989 by: Robert Cummings

Re: PHP with XML database
        247986 by: Richard Lynch
        247987 by: Richard Lynch
        248000 by: Ritesh Nadhani

Re: __construct __destruct in PHP 4
        247990 by: Gregory Beaver

Re: My objects eats too much (and weird!) memory
        247992 by: Richard Lynch

Re: memory_limit Setting?
        247993 by: Richard Lynch

Re: php code to upload a url correctly
        247995 by: Richard Lynch

Re: Ongoing encoding issues
        247996 by: Richard Lynch
        247999 by: Richard Lynch

Re: two php.ini on the same server
        247997 by: Richard Lynch
        248009 by: Pierre Pintaric

Re: Suggestions of GPL plugin-system?
        247998 by: Larry Garfield
        248003 by: Robert Cummings
        248004 by: Larry Garfield

Re: PHP 5.2.0 + qmail problem
        248002 by: Richard Lynch

time
        248005 by: Richard Kurth
        248006 by: Jay Blanchard
        248007 by: tom
        248008 by: Richard Kurth
        248012 by: Jim Lucas
        248021 by: Bob Dusek

Parsing mail file
        248010 by: Pierre Pintaric
        248011 by: Pierre Pintaric
        248013 by: Jim Lucas
        248014 by: Pierre Pintaric
        248016 by: Roman Neuhauser
        248017 by: Pierre Pintaric
        248018 by: Mauro Lorenzutti
        248019 by: Dotan Cohen
        248020 by: Roman Neuhauser

Administrivia:

To subscribe to the digest, e-mail:
        php-general-digest-subscribelists.php.net

To unsubscribe from the digest, e-mail:
        php-general-digest-unsubscribelists.php.net

To post to the list, e-mail:
        php-generallists.php.net

----------------------------------------------------------------------

attached mail follows:


# ceol-i-e.com / 2007-01-29 17:54:03 -0600:
> MySQL is the *only* db engine that lets you get away with [bleep] like
> apostrophes around numbers.

Actually, these are examples of valid SQL: INTEGER '1', FLOAT '13.5'.

test=# select version();
                                             version
-------------------------------------------------------------------------------------------------
 PostgreSQL 8.1.3 on amd64-portbld-freebsd6.1, compiled by GCC cc (GCC) 3.4.4 [FreeBSD] 20050518
(1 row)

test=# select '13.5' * '30';
ERROR: operator is not unique: "unknown" * "unknown"
test=# select float '13.5' * integer '10';
 ?column?
----------
      135
(1 row)

test=# create table t (f float, i integer);
CREATE TABLE
test=# insert into t values ('13.5', '10');
INSERT 0 1
test=# select * from t;
  f | i
------+----
 13.5 | 10
(1 row)

--
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man. You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

attached mail follows:


On Mon, January 29, 2007 6:55 pm, Roman Neuhauser wrote:
> # ceol-i-e.com / 2007-01-29 17:54:03 -0600:
>> MySQL is the *only* db engine that lets you get away with [bleep]
>> like
>> apostrophes around numbers.
>
> Actually, these are examples of valid SQL: INTEGER '1', FLOAT '13.5'.

> test=# select float '13.5' * integer '10';
> ?column?
> ----------
> 135
> (1 row)

Errrr.

Yes, you can TYPE-CAST string data into integer/float data...

But you are INPUTTING string data at that point, not numeric, and
forcing PostgreSQL to convert it internally.

It's the exact analog of:

<?php
  $foo = '1';
  $foo = (int) $foo;
  echo gettype($foo);
  $bar = 1;
  echo gettype($bar);
?>

> test=# create table t (f float, i integer);
> CREATE TABLE
> test=# insert into t values ('13.5', '10');
> INSERT 0 1
> test=# select * from t;
> f | i
> ------+----
> 13.5 | 10
> (1 row)

I'm amazed this worked and didn't error out...

It definitely USED to error out.

Looks like PostgreSQL caved in to the unwashed masses of MySQL users
who couldn't handle not putting apostrophes around everything to me...
[sigh]
:-) :-) :-)

Oh well.

I personally would prefer that the DB not accept bogus input like this.

Different strokes for different folks.

--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

attached mail follows:


On Monday 29 January 2007 7:19 pm, Richard Lynch wrote:

> Looks like PostgreSQL caved in to the unwashed masses of MySQL users
> who couldn't handle not putting apostrophes around everything to me...
> [sigh]
>
> :-) :-) :-)
>
> Oh well.
>
> I personally would prefer that the DB not accept bogus input like this.
>
> Different strokes for different folks.

Different strokes indeed. Personally I'd much rather one be able to just
say "quote a literal, dagnabbit" and not worry about whether it was a string
or an int. I'm sure there's some reason for it deep in the bowels of SQL
engines as they existed in the early '80s, but for anyone trying to not
hand-write every frickin' SQL query and automate common tasks it makes life
considerably more annoying.

--
Larry Garfield AIM: LOLG42
larrygarfieldtech.com ICQ: 6817012

"If nature has made any one thing less susceptible than all others of
exclusive property, it is the action of the thinking power called an idea,
which an individual may exclusively possess as long as he keeps it to
himself; but the moment it is divulged, it forces itself into the possession
of every one, and the receiver cannot dispossess himself of it." -- Thomas
Jefferson

attached mail follows:


On Mon, January 29, 2007 7:43 pm, Larry Garfield wrote:
> On Monday 29 January 2007 7:19 pm, Richard Lynch wrote:
>
>> Looks like PostgreSQL caved in to the unwashed masses of MySQL users
>> who couldn't handle not putting apostrophes around everything to
>> me...
>> [sigh]
>>
>> :-) :-) :-)
>>
>> Oh well.
>>
>> I personally would prefer that the DB not accept bogus input like
>> this.
>>
>> Different strokes for different folks.
>
> Different strokes indeed. Personally I'd much rather one be able to
> just
> say "quote a literal, dagnabbit" and not worry about whether it was a
> string
> or an int. I'm sure there's some reason for it deep in the bowels of
> SQL
> engines as they existed in the early '80s, but for anyone trying to
> not
> hand-write every frickin' SQL query and automate common tasks it makes
> life
> considerably more annoying.

I can see where you are coming from, but if you don't know what data
type you have, and what data type you are using in SQL, you're already
screwed. :-)

--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

attached mail follows:


On Sat, January 27, 2007 7:00 pm, Jochem Maas wrote:
> objects are always by reference in php5 - in php4 you have to
> use the 'reference' operator (the symbol) to make object be passed
> by reference.

[pedantic for="archives"]
Not the symbol, which suppresses errors, but the & symbol which
forces a reference instead of a copy.
[/pedantic]

--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

attached mail follows:


Richard Lynch wrote:
> On Sat, January 27, 2007 7:00 pm, Jochem Maas wrote:
>> objects are always by reference in php5 - in php4 you have to
>> use the 'reference' operator (the symbol) to make object be passed
>> by reference.
>
> [pedantic for="archives"]
> Not the symbol, which suppresses errors, but the & symbol which
> forces a reference instead of a copy.
> [/pedantic]

ah yes - whoops - my bad, twas probably late and I wasn't paying attention anymore.

>

attached mail follows:


On Fri, January 26, 2007 3:09 pm, Ken Kixmoeller -- reply to
kenkixmoeller.com wrote:
> I want to have an multidimensional array as a property of an object.

While not relevant to your immediate question, you may want to be told
that PHP arrays are not truly multi-dimensional, but nested.

I.e., one cannot do:
$foo[0] = 'bar';
$foo[0][] = 'baz';

$foo[0] can hold a value, or another array, but not both.

This confuses some "converts" from other languages which store data
differently in a "true" multi-dimensional fashion.

YMMV
NAIAA

--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

attached mail follows:


On Mon, 2007-01-29 at 17:12 -0600, Richard Lynch wrote:
> On Mon, January 29, 2007 11:20 am, Ken Dozier wrote:
> > Does in_array() use a search algorithm (i.e., binary search), or does
> > it
> > check sequentially each element in the array?
>
> Since there is no guarantee that the elements are in any particular
> order, it almost has to be sequential...

There's no guarantee that the keys are in any particular order either
though... but the keys do receive special treatment :)

> Ideal #2:
> Put the values in as keys, and use http://php.net/isset
> This will "hash" the values and have an O(1) lookup, I think.

Only perfect hashes have O(1) lookup, and in practice there are very few
perfect hashes set up in reality since the cost to produce a perfect
hash outweighs the time necessary to find the value. You'll find that
most lookup systems are on the order of O( lg n ). PHP is no exception.

Cheers,
Rob.
--
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting |
| a powerful, scalable system for accessing system services |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for |
| creating re-usable components quickly and easily. |
`------------------------------------------------------------'

attached mail follows:


On Mon, January 29, 2007 7:03 pm, Robert Cummings wrote:
> On Mon, 2007-01-29 at 17:12 -0600, Richard Lynch wrote:
>> On Mon, January 29, 2007 11:20 am, Ken Dozier wrote:
>> > Does in_array() use a search algorithm (i.e., binary search), or
>> does
>> > it
>> > check sequentially each element in the array?
>>
>> Since there is no guarantee that the elements are in any particular
>> order, it almost has to be sequential...
>
> There's no guarantee that the keys are in any particular order either
> though... but the keys do receive special treatment :)
>
>> Ideal #2:
>> Put the values in as keys, and use http://php.net/isset
>> This will "hash" the values and have an O(1) lookup, I think.
>
> Only perfect hashes have O(1) lookup, and in practice there are very
> few
> perfect hashes set up in reality since the cost to produce a perfect
> hash outweighs the time necessary to find the value. You'll find that
> most lookup systems are on the order of O( lg n ). PHP is no
> exception.

I rememberd that after I hit "Send"

Oh well.

It's still way the hell better than what we suspect in_array() does.

--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

attached mail follows:


On Mon, 2007-01-29 at 19:14 -0600, Richard Lynch wrote:
> On Mon, January 29, 2007 7:03 pm, Robert Cummings wrote:
> >
> > Only perfect hashes have O(1) lookup, and in practice there are very
> > few
> > perfect hashes set up in reality since the cost to produce a perfect
> > hash outweighs the time necessary to find the value. You'll find that
> > most lookup systems are on the order of O( lg n ). PHP is no
> > exception.
>
> I rememberd that after I hit "Send"
>
> Oh well.

:)

> It's still way the hell better than what we suspect in_array() does.

For sure.

Cheers,
Rob.
--
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting |
| a powerful, scalable system for accessing system services |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for |
| creating re-usable components quickly and easily. |
`------------------------------------------------------------'

attached mail follows:


On Fri, January 26, 2007 2:36 pm, Ritesh Nadhani wrote:
> Hello all
>
> As part of my research under my professor I have to implement a web
> interface to their benchmarking data.
>
> PHP is the chosen web language but we are little worried about the
> database. The benchmark data comes to us in XML format (e.g.
> http://www.matf.bg.ac.yu/~filip/ArgoLib/smt-lib-xml/Examples/FolEq1.xml).
> We have to implement an interface to query them, get data, update etc.
>
> We even can change schema in the form of attributes. . The data size
> would be around 100 MB each XML with around 100 different XMLs.
>
> The load would be max 5-10 users any given time, batch updates once a
> month and heavy load probably 2-3 times a month. Mission criticality
> is
> not important, we can get it down sometimes. Which db would you
> suggest?
>
> I did Google research and as of now - I like eXist, Sedna (they seem
> to
> have good PHP wrapper support) and Timber. Another thing would be good
> documentation and support.
>
> Any suggestions?

MySQL with the XML Engine would be my first suggestion to check out.

You would just slurp down the XML and then use simple standard SQL
queries on the local copy.

I dunno how fast/stable it is, nor even what version of MySQL it
appears in, but it's there somewhere.

There are almost for sure other more common RDBMS that let you
"pretend" that XML is just another database storage file format, and
run regular old SQL queries on it. I think PostgreSQL can do this,
actually. I wouldn't be shocked to find out that SQL Server even has
something truly ugly to do it, but it would work.

An even simpler method, if you only get updates once a month, would be
to write a monthly "import" script that just loads in the XML to a
normal database, with some kind of automated conversion of the XML
attributes/tags to column names.

--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

attached mail follows:


On Fri, January 26, 2007 6:10 pm, Ritesh Nadhani wrote:
> Hello
>
> Bernhard Zwischenbrugger wrote:
>> Hi
>>
>> Some questions
>>
>>> As part of my research under my professor I have to implement a web
>>> interface to their benchmarking data.
>>>
>>> PHP is the chosen web language but we are little worried about the
>>> database. The benchmark data comes to us in XML format (e.g.
>>> http://www.matf.bg.ac.yu/~filip/ArgoLib/smt-lib-xml/Examples/FolEq1.xml).
>>> We have to implement an interface to query them, get data, update
>>> etc.
>>
>> You can parse the XML, extract the data, put it to an SQL DB and
>> move
>> the XML to /dev/null (delete it).
>> If you do that, you don't need an XML DB.
>> Is this possible?
>>
>
> No. My professor is dead against that. Many people have suggested me
> doing that. Why? Are XML databases incorrectly implemented or are bad?

I think it's safe to say that at least some XML databases are
incorrectly implemented, or even bad. :-)

The answers you keep getting are because without a driving reason to
use the features specific to XML, using XML as the database backend is
probably a Bad Idea.

So unless you explain WHY you want the XML db, and unless those
reasons make sense to need an XML db, you'll keep getting people
telling you, effectively, to "Don't do that."

>>> We even can change schema in the form of attributes. . The data
>>> size
>>> would be around 100 MB each XML with around 100 different XMLs.
>>
>> What do you mean by "different XMLs"?
>> Are you looking for a maschine that makes SQL Tables from XML?
>> What is inside of the 100MB XML? Your example is a MathML Formula.
>>
>
> By different XMLs I meants, different XML files. So we can have 40 XML
> files with around 50-100 MB each.
>
> Yes, they will have lot sof those MathML formulas. Its benchmarking
> data
> from some theoritical group that my professor works with. They have
> all
> their database in XML so relational database is not possible otherwise
> we will have to convert them between XML and relational all the time.

How exactly will your converted XML get folded back into the other
data stores?...

This is your big challenge, upon which everything else hinges.

>>> The load would be max 5-10 users any given time, batch updates once
>>> a
>>> month and heavy load probably 2-3 times a month. Mission
>>> criticality is
>>> not important, we can get it down sometimes. Which db would you
>>> suggest?

You have to define "heavy load" unless your max 5-10 *is* the "heavy
load" in which case you'd have to work hard to screw this up enough to
not be able to handle the load, I think...

Though I dunno for sure what performance of XML backend is like...

>>> I did Google research and as of now - I like eXist, Sedna (they
>>> seem to
>>> have good PHP wrapper support) and Timber. Another thing would be
>>> good
>>> documentation and support.

I've never even heard of eXist nor Sedna, which is why I'm suggesting
you choose something a bit (okay a LOT) more mainstream like MySQL,
where you'll have zillions of fellow users to help out.

> So my question is: out of the six systems listed above, which one you
> would suggest? Has anybody used any of the above system before? What
> are
> your experiences?

I've never actually been silly enough to insist on storying actual
data as XML and pretending it's a DB, rather than storing it as DB and
then writing scripts to output it as if it were XML...

Unless you've got shared data segments scattered all across the world,
forcing it all into XML is probably the First Mistake. But since
that's your professors' problem, and not yours, I can see how you've
got little choice in the matter.

--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

attached mail follows:


Thank you Bernhard and Richard

Your comments have been really helpful. I have a meeting with the
professor on Wednesday and I will lay down all this points in front of
him then.

On 1/29/07, Richard Lynch <ceol-i-e.com> wrote:
> On Fri, January 26, 2007 6:10 pm, Ritesh Nadhani wrote:
> > Hello
> >
> > Bernhard Zwischenbrugger wrote:
> >> Hi
> >>
> >> Some questions
> >>
> >>> As part of my research under my professor I have to implement a web
> >>> interface to their benchmarking data.
> >>>
> >>> PHP is the chosen web language but we are little worried about the
> >>> database. The benchmark data comes to us in XML format (e.g.
> >>> http://www.matf.bg.ac.yu/~filip/ArgoLib/smt-lib-xml/Examples/FolEq1.xml).
> >>> We have to implement an interface to query them, get data, update
> >>> etc.
> >>
> >> You can parse the XML, extract the data, put it to an SQL DB and
> >> move
> >> the XML to /dev/null (delete it).
> >> If you do that, you don't need an XML DB.
> >> Is this possible?
> >>
> >
> > No. My professor is dead against that. Many people have suggested me
> > doing that. Why? Are XML databases incorrectly implemented or are bad?
>
> I think it's safe to say that at least some XML databases are
> incorrectly implemented, or even bad. :-)
>
> The answers you keep getting are because without a driving reason to
> use the features specific to XML, using XML as the database backend is
> probably a Bad Idea.
>
> So unless you explain WHY you want the XML db, and unless those
> reasons make sense to need an XML db, you'll keep getting people
> telling you, effectively, to "Don't do that."
>
> >>> We even can change schema in the form of attributes. . The data
> >>> size
> >>> would be around 100 MB each XML with around 100 different XMLs.
> >>
> >> What do you mean by "different XMLs"?
> >> Are you looking for a maschine that makes SQL Tables from XML?
> >> What is inside of the 100MB XML? Your example is a MathML Formula.
> >>
> >
> > By different XMLs I meants, different XML files. So we can have 40 XML
> > files with around 50-100 MB each.
> >
> > Yes, they will have lot sof those MathML formulas. Its benchmarking
> > data
> > from some theoritical group that my professor works with. They have
> > all
> > their database in XML so relational database is not possible otherwise
> > we will have to convert them between XML and relational all the time.
>
> How exactly will your converted XML get folded back into the other
> data stores?...
>
> This is your big challenge, upon which everything else hinges.
>
> >>> The load would be max 5-10 users any given time, batch updates once
> >>> a
> >>> month and heavy load probably 2-3 times a month. Mission
> >>> criticality is
> >>> not important, we can get it down sometimes. Which db would you
> >>> suggest?
>
> You have to define "heavy load" unless your max 5-10 *is* the "heavy
> load" in which case you'd have to work hard to screw this up enough to
> not be able to handle the load, I think...
>
> Though I dunno for sure what performance of XML backend is like...
>
> >>> I did Google research and as of now - I like eXist, Sedna (they
> >>> seem to
> >>> have good PHP wrapper support) and Timber. Another thing would be
> >>> good
> >>> documentation and support.
>
> I've never even heard of eXist nor Sedna, which is why I'm suggesting
> you choose something a bit (okay a LOT) more mainstream like MySQL,
> where you'll have zillions of fellow users to help out.
>
> > So my question is: out of the six systems listed above, which one you
> > would suggest? Has anybody used any of the above system before? What
> > are
> > your experiences?
>
> I've never actually been silly enough to insist on storying actual
> data as XML and pretending it's a DB, rather than storing it as DB and
> then writing scripts to output it as if it were XML...
>
> Unless you've got shared data segments scattered all across the world,
> forcing it all into XML is probably the First Mistake. But since
> that's your professors' problem, and not yours, I can see how you've
> got little choice in the matter.
>
> --
> Some people have a "gift" link here.
> Know what I want?
> I want you to buy a CD from some starving artist.
> http://cdbaby.com/browse/from/lynch
> Yeah, I get a buck. So?
>
>

--
Ritesh
http://www.riteshn.com

attached mail follows:


Peter Lauri wrote:
> Hi,
>
>
>
> I have been trying going thru the PHP manual to find if there are any
> equivalent to the __contruct and __destruct in PHP 4, but I cannot find any
> solution for this part. I know it was introduced in PHP 5, but as __sleep
> and __wakeup exist in PHP 4 already I was hoping there is something like
> __init and __die in PHP 4 :-)

Hi Peter,

As you probably already know, PHP 4 constructors are functions named
after the class

<?php
class Foo
{
    function Foo()
    {
        echo "in constructor";
    }
}
$a = new Foo;
?>

Although destructor emulation is implemented in the PEAR class
(destructor would be function _Foo), I don't recommend using a
destructor in PHP 4. Instead, manually destruct your objects. PEAR
does it with a shutdown function, so if performance is not a question,
by all means, use PEAR's implementation. It has been battle-tested for
years and years.

However, I wouldn't bother with writing new code in PHP 4. It will be
cheaper for you to switch hosting providers to one that allows you to
use PHP 5. Why? You will waste tons of time working around reference
issues that are non-existent in PHP 5 due to object handles.

Greg

attached mail follows:


On Sat, January 27, 2007 2:12 pm, Francisco M. Marzoa Alonso wrote:
> On sáb, 2007-01-27 at 20:05 +0000, Roman Neuhauser wrote:
>> # franciscomarzoa.com / 2007-01-26 20:40:34 +0100:
>> > I've written this to check memory consumption of PHP5 objects,
>> because
>> > I'm having memory problems with an OO XMLParser that I've written.
>>
>> It measures something else though. The memory manager doesn't
>> allocate
>> memory for individual variables in PHP.
>>
>> > $ php MemTest.php
>> > Obj1 uses 208 bytes
>> > Obj2 uses 168 bytes
>> > Obj3 uses 200 bytes
>> > Obj4 uses 200 bytes
>> > Obj5 uses 200 bytes
>> > Obj6 uses 200 bytes
>> >
>> >
>> > I understand that first instance may be bigger than next ones
>> because
>> > method allocation and other things of that kind
>>
>> No.
>>
>> > but I do not understand why second instance is smaller than third
>> :-?
>>
>> It's not.

I believe PHP 5 allocates memory in "chunks" and then parcels it out
to your objects as needed.

I also *think* Roman was pointing out that you were not subtracting
the original memory_get_usage() from before/after in a consistent way
to actually find out how much each object was using.

All that said, 200 bytes for the object may or may not be excessive,
but you'd have to read PHP source to see what it's doing to see for
sure.

And absolutely for certain, there's no "compact mode" to run in where
objects take less RAM.

So if you're not happy with the RAM usage of objects, stop using
objects. :-)

--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

attached mail follows:


On Fri, January 26, 2007 11:35 am, Jay Paulson wrote:
> Hi everyone,
>
> I¹m trying to upload a 25MB file via PHP and I¹m setting the memory
> limit
> way high so I don¹t get a fatal error from php (the error is below).
> What I
> find really odd about this is that the error message says that PHP
> tried to
> allocate almost 54MB. First question is why is PHP allocating so much
> memory when I¹m only uploading a 25MB file? Second question is why is
> PHP
> failing when obviously the memory limit is set to just over 100MB?
> (I¹m
> using PHP 5.1.2 Apache 2.0.55 and using an .htaccess file to change
> the PHP
> settings on the fly.)
>
>
> Fatal error: Allowed memory size of 104857600 bytes exhausted (tried
> to
> allocate 53764163 bytes) in /path/to/php/file on line 942
>
> .htaccess settings below:
>
> php_value memory_limit 100M
> php_value post_max_size 30M
> php_value upload_max_filesize 30M
> php_value max_execution_time 300
> php_value max_input_time 300
> php_value display_errors On

The real question is how did you manage to use up 75 Meg in the first
941 lines of your code?... :-)

Actually, look at phpinfo() output to be SURE your .htaccess values
are kicking in. If they don't show up under the "Local" column, your
.htaccess isn't working.

--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

attached mail follows:


On Fri, January 26, 2007 8:10 am, Corden James (RW3) CM&MC Manchester
wrote:
> I have a form in which users submit a url. I am having problems as
> some
> people submit the url in the format http://www.blah.blah.org
> <http://www.blah.blah.org/> while others submit in the format
> www.blah.blah.org <http://www.blah.blah.org/> I have designed the
> form
> so that it seems fairly obvious (to me anyway) not to include the
> http:// but people are still doing it (presumably because they are
> copying and pasting from a browser). My form processing script is
> designed to add http:// to the submitted url and place the modified
> url
> in a database for future use. As you can imagine sometimes I end up
> with
> urls such as http://http://www.blah.blah.org
> <http://http:/www.blah.blah.org> in my database. Hence I need a more
> rigorous form processing script that is capable of first checking if
> the
> url includes http:// and then processes accordingly. Can anyone point
> me
> in the right direction for such a script?

Perhaps you could do this:
if (strtolower(substr($input, 0, 7)) === 'http://') $input =
substr($input, 7);

What I tend to do, however, is just check on output:
if (!stristr($link, 'http://')) $link = "http://$link";

Yes, this means that I may be re-doing the operation a zillion times
at output instead of once at input, but it also means that users
aren't miffed that I took their URL and "changed" it out from under
them when they go back to edit it.

There is also the nifty http://php.net/parse_url which might be smart
enough to default to 'http://' and then you could assemble the URL.

Depends how funky the URLs might get -- Mine are always just
homepages, so don't have much in the way of weird complex URL issues
like #fragment or GET parameters.

One other suggestion:

You could use http://php.net/fopen to find out if the link is valid at
the time of input.

This will slow down input considerably, but can help catch typos in URLs.

You could even go so far as to "read" the beginning of the HTML and
see if there is a TITLE tag, and present that to the user to confirm
it's the page they meant...

Though there's an awful lot of bad HTML out there with no title tag.
:-( So then you need an extra check for that, and a fallback like the
first non-tag line of the body or the META description if it's there
or...

This presumes allow_url_fopen is "on" in php.ini, which might not be
true for security reasons.

--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

attached mail follows:


On Fri, January 26, 2007 3:33 am, Dave Goodchild wrote:
> Hi all, I posted a question a couple of days ago regarding a web app I
> have
> wherein users are able to indicated prices and concessions via a text
> field,
> and the resulting encoding issues I have experienced, the main one
> being
> seeing the pound sign as £ if viewing the results in a browser with
> the
> encoding set to Latin-1.
>
> My question is, how do I overcome this. If I set my browser encoding
> to
> Latin-1 and enter the data I get that odd symbol, if I set it to UTF-8
> I get
> clean data. Is there a way to sniff out what encoding the browser is
> using
> and then clean the data in any way.
>
> I am googling for help also but you guys have been so helpful in the
> past I
> thought I'd try you also.

Send the charset in your headers *AND* set it in a META tag.

Firefox trusts the headers.
IE trusts the META tag.

If the user insists on viewing your UTF-8 document with Latin-1 after
that, then they probably had to work pretty hard at it, and you should
just leave them alone with the bed they have made.

--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

attached mail follows:


On Fri, January 26, 2007 7:24 am, Jochem Maas wrote:
> Dave Goodchild wrote:
> that said you should probably opt to output everything as UTF-8 - all
> decent
> browsers will return data in the same encoding as the page was given
> to them in
> by default - this requires you to have php send the correct header
> (don't
> bother with all that META tag crap), doing the following will
> automatically cause
> the appropriate header to be sent:

*Do* bother with the META tag crap.

MS IE will ignore the headers and attempt to "guess" the charset
otherwise, based on some funky algorithm they've made up to compare
the bytes in the HTML to what they "expect" for any given charset, and
you'll get weird and confusing cases when the same "page" won't be
UTF-8 just because the data within it suddenly tips over their
count-point of what "should" be in a UTF-8 or Latin-1 document.

Don't blame me -- I'm just reporting the behaviour. Talk to Bill.

--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

attached mail follows:


On Fri, January 26, 2007 6:36 am, phpdevster wrote:
> Hi
>
> i am trying to run two Apache server on the same machine and that is
> work
> fine
>
> but the problem is how to create separate php.ini for each Apache
> server .
> is that possible ??

In Apache 2, there is a PHPIniDir directive, I do believe...

--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

attached mail follows:


Richard Lynch a écrit :
> On Fri, January 26, 2007 6:36 am, phpdevster wrote:
>
>> Hi
>>
>> i am trying to run two Apache server on the same machine and that is
>> work
>> fine
>>
>> but the problem is how to create separate php.ini for each Apache
>> server .
>> is that possible ??
>>
>
> In Apache 2, there is a PHPIniDir directive, I do believe...
>
>

You have the directive to load your config file: suPHP_ConfigPath

good luck

attached mail follows:


I was looking for a similar good-example about 2 years ago. What I found was
Drupal (http://drupal.org/), and it's hook system. I have since given up on
writing my own plugin system and became a small fry Drupal developer. :-)

YMMV.

On Monday 29 January 2007 6:50 am, Ivo F.A.C. Fokkema wrote:
> Hi guys,
>
> I've been developing a GPL PHP/MySQL app for some time now and I would
> like to extend it with a module/plugin system. The idea would be that
> people could add a directory in a plugin path that would contain a
> bunch of PHP files extending the functionality of my application. This
> directory would then be read out, some config file parsed and whatnot,
> after which the module can be turned on by my application.
>
> Now, I could try and figure this out by myself, but that would be
> reinventing the wheel since I'm betting there is some good GPL modular
> software around (such as Joomla, PHP-Nuke, PHPbb, etc, etc.) that you have
> been working with as a coder. Could any of you suggest a certain GPL
> application that has a great module setup that I could take a look at?
>
> Thanks a lot for your time!
>
> Ivo

--
Larry Garfield AIM: LOLG42
larrygarfieldtech.com ICQ: 6817012

"If nature has made any one thing less susceptible than all others of
exclusive property, it is the action of the thinking power called an idea,
which an individual may exclusively possess as long as he keeps it to
himself; but the moment it is divulged, it forces itself into the possession
of every one, and the receiver cannot dispossess himself of it." -- Thomas
Jefferson

attached mail follows:


On Mon, 2007-01-29 at 20:02 -0600, Larry Garfield wrote:
> I was looking for a similar good-example about 2 years ago. What I found was
> Drupal (http://drupal.org/), and it's hook system. I have since given up on
> writing my own plugin system and became a small fry Drupal developer. :-)
>
> YMMV.

Be prepared to cry sometimes when you have to do 10 times the usual work
to work around the Drupal system... that said, it's quite nice even
though terribly inefficient with all the layers of wrapping hooks.

On another up side, if you don't know how to do CSS properly, Drupal
will hammer proper CSS usage into you as you try to style menus and
other modules.

Cheers,
Rob.
--
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting |
| a powerful, scalable system for accessing system services |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for |
| creating re-usable components quickly and easily. |
`------------------------------------------------------------'

attached mail follows:


On Monday 29 January 2007 8:37 pm, Robert Cummings wrote:
> On Mon, 2007-01-29 at 20:02 -0600, Larry Garfield wrote:
> > I was looking for a similar good-example about 2 years ago. What I found
> > was Drupal (http://drupal.org/), and it's hook system. I have since
> > given up on writing my own plugin system and became a small fry Drupal
> > developer. :-)
> >
> > YMMV.
>
> Be prepared to cry sometimes when you have to do 10 times the usual work
> to work around the Drupal system... that said, it's quite nice even
> though terribly inefficient with all the layers of wrapping hooks.

There is no problem in computer science that cannot be solved by adding
another layer of indirection, except performance. :-)

When you really get into complex stuff, yes, you really have to make sure you
think about a problem the "Drupal Way". Of course, you could say the same
for pretty much any complete framework. Drupal is all about doing
things "sideways" for maximum flexibility and extensibility, which does come
at a penalty of conceptual complexity.

> On another up side, if you don't know how to do CSS properly, Drupal
> will hammer proper CSS usage into you as you try to style menus and
> other modules.

Also true. :-)

--
Larry Garfield AIM: LOLG42
larrygarfieldtech.com ICQ: 6817012

"If nature has made any one thing less susceptible than all others of
exclusive property, it is the action of the thinking power called an idea,
which an individual may exclusively possess as long as he keeps it to
himself; but the moment it is divulged, it forces itself into the possession
of every one, and the receiver cannot dispossess himself of it." -- Thomas
Jefferson

attached mail follows:


On Fri, January 26, 2007 2:01 am, Bc. Radek Krejca wrote:
> Hello,
>
> I had to change my mailserver from sendmail to qmail. After it I saw
> that the mail generated by function mail() has 2 newlines in body
> except 1.
> I have this konfiguration on server with php4xx and no problem is
> there. Also if I change back sendmail so it is working too.

You will probably have better luck on a qmail list, since PHP is doing
the exact same thing in both cases...

--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

attached mail follows:


I am writing a program for managing leads and contacts. I would like to add
the ability to see what TIME it is where the contact is not there server
time. So if you looked at a list of contacts from all over the country you
would see different times compared to what time it is where the user is at.
What should I be looking at to calculate out the different time zones. Could
somebody just point me in the write direction at this time I have no idea on
how to proceeded.

attached mail follows:


[snip]
I am writing a program for managing leads and contacts. I would like to
add
the ability to see what TIME it is where the contact is not there server
time. So if you looked at a list of contacts from all over the country
you
would see different times compared to what time it is where the user is
at.
What should I be looking at to calculate out the different time zones.
Could
somebody just point me in the write direction at this time I have no
idea on
how to proceeded.
[/snip]

You would use JavaScript to capture their local 'browser' time and
process it with PHP

attached mail follows:


test
Jay Blanchard :
> [snip]
> I am writing a program for managing leads and contacts. I would like to
> add
> the ability to see what TIME it is where the contact is not there server
> time. So if you looked at a list of contacts from all over the country
> you
> would see different times compared to what time it is where the user is
> at.
> What should I be looking at to calculate out the different time zones.
> Could
> somebody just point me in the write direction at this time I have no
> idea on
> how to proceeded.
> [/snip]
>
> You would use JavaScript to capture their local 'browser' time and
> process it with PHP

attached mail follows:


[snip]
I am writing a program for managing leads and contacts. I would like to add
the ability to see what TIME it is where the contact is not there server
time. So if you looked at a list of contacts from all over the country you
would see different times compared to what time it is where the user is at.
What should I be looking at to calculate out the different time zones.
Could
somebody just point me in the write direction at this time I have no idea on
how to proceeded.
[/snip]

You would use JavaScript to capture their local 'browser' time and process
it with PHP

I am not looking for something where I am on line with these people some do
not have internet access. I would be calling them on the phone.
I need a way to get the time at there location using what info I already
have like the address zip code and phone number. It would probably have to
be compared to a database of some sort or the time zone file on a lynx
server.

attached mail follows:


Richard Kurth wrote:
> [snip]
> I am writing a program for managing leads and contacts. I would like to add
> the ability to see what TIME it is where the contact is not there server
> time. So if you looked at a list of contacts from all over the country you
> would see different times compared to what time it is where the user is at.
> What should I be looking at to calculate out the different time zones.
> Could
> somebody just point me in the write direction at this time I have no idea on
> how to proceeded.
> [/snip]
>
> You would use JavaScript to capture their local 'browser' time and process
> it with PHP
>
> I am not looking for something where I am on line with these people some do
> not have internet access. I would be calling them on the phone.
> I need a way to get the time at there location using what info I already
> have like the address zip code and phone number. It would probably have to
> be compared to a database of some sort or the time zone file on a lynx
> server.
>
You are going to need the info found at www.melissadata.com

Something like a LERG database/cross reference

Jim

attached mail follows:


If you have the timezone offset stored for each contact, you can compare
that to the timezone offset of the server and do the math on a timestamp
value.
 
// return value format: hhmm
// -0500 for US/EST, -5 hours relative to GMT
$timeZoneOfServer = date("O");

> -----Original Message-----
> From: Richard Kurth [mailto:richardkurthcenturytel.net]
> Sent: Tuesday, January 30, 2007 12:12 AM
> To: php-generallists.php.net
> Subject: RE: [PHP] time
>
> [snip]
> I am writing a program for managing leads and contacts. I
> would like to add
> the ability to see what TIME it is where the contact is not
> there server
> time. So if you looked at a list of contacts from all over
> the country you
> would see different times compared to what time it is where
> the user is at.
> What should I be looking at to calculate out the different time zones.
> Could
> somebody just point me in the write direction at this time I
> have no idea on
> how to proceeded.
> [/snip]
>
> You would use JavaScript to capture their local 'browser'
> time and process
> it with PHP
>
> I am not looking for something where I am on line with these
> people some do
> not have internet access. I would be calling them on the phone.
> I need a way to get the time at there location using what
> info I already
> have like the address zip code and phone number. It would
> probably have to
> be compared to a database of some sort or the time zone file on a lynx
> server.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

attached mail follows:


Hello there,

I'm sure this question was ask 1,000 times, but I didn't find any
archive about this, that's why I need help...

Here is my problem:
I receive mail file from my MTA (ie QMail), that works fine. Now, I
would to find a class or a function that parse the mail and gives
headers informations, body of the mail (even if it is a multi-part mail)
and file attachments.
I found nothing in PEAR library, nothing on the web, ...

I don't what want to rebuild the wheel if somebody works on it and made
a good job...
If somebody uses a great function and want to share, I will please
him... :-)

Thanks for your help.

Pierre

attached mail follows:


Hello there,

I'm sure this question was ask 1,000 times, but I didn't find any
archive about this, that's why I need help...

Here is my problem:
I receive mail file from my MTA (ie QMail), that works fine. Now, I
would to find a class or a function that parse the mail and gives
headers informations, body of the mail (even if it is a multi-part mail)
and file attachments.
I found nothing in PEAR library, nothing on the web, ...

I don't what want to rebuild the wheel if somebody works on it and made
a good job...
If somebody uses a great function and want to share, I will please
him... :-)

Thanks for your help.

Pierre

attached mail follows:


Pierre Pintaric wrote:
> Hello there,
>
> I'm sure this question was ask 1,000 times, but I didn't find any
> archive about this, that's why I need help...
>
> Here is my problem:
> I receive mail file from my MTA (ie QMail), that works fine. Now, I
> would to find a class or a function that parse the mail and gives
> headers informations, body of the mail (even if it is a multi-part mail)
> and file attachments.
> I found nothing in PEAR library, nothing on the web, ...
>
> I don't what want to rebuild the wheel if somebody works on it and made
> a good job...
> If somebody uses a great function and want to share, I will please
> him... :-)
>
> Thanks for your help.
>
> Pierre
>

google.com and ask for php web mail client

This will return you many different examples of php programs that have
the function/class that you are looking for.

attached mail follows:


Jim Lucas a écrit :
> Pierre Pintaric wrote:
>> Hello there,
>>
>> I'm sure this question was ask 1,000 times, but I didn't find any
>> archive about this, that's why I need help...
>>
>> Here is my problem:
>> I receive mail file from my MTA (ie QMail), that works fine. Now, I
>> would to find a class or a function that parse the mail and gives
>> headers informations, body of the mail (even if it is a multi-part
>> mail) and file attachments.
>> I found nothing in PEAR library, nothing on the web, ...
>>
>> I don't what want to rebuild the wheel if somebody works on it and
>> made a good job...
>> If somebody uses a great function and want to share, I will please
>> him... :-)
>>
>> Thanks for your help.
>>
>> Pierre
>>
>
> google.com and ask for php web mail client
>
> This will return you many different examples of php programs that have
> the function/class that you are looking for.
>

Of course, I looked for that, in PEAR, you can find Mail::IMAP and
Mail::MBox...
All this exemples connect to an IMAP server or to a MBox file, I would
only parse an email file...

attached mail follows:


# pierre.pintaricmatrice.com / 2007-01-30 10:18:54 +0100:
> I receive mail file from my MTA (ie QMail), that works fine. Now, I
> would to find a class or a function that parse the mail and gives
> headers informations, body of the mail (even if it is a multi-part mail)
> and file attachments.
> I found nothing in PEAR library, nothing on the web, ...

That's probably because you don't know enough about the field to use the
right search terms, since PEAR *does* contain a package for parsing email
messages, and I have no problems arriving at it from the search box
on http://pear.php.net/ ...

ftp://ftp.rfc-editor.org/in-notes/rfc2045.txt

--
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man. You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991

attached mail follows:


Roman Neuhauser a écrit :
> That's probably because you don't know enough about the field to use the
> right search terms, since PEAR *does* contain a package for parsing email
> messages, and I have no problems arriving at it from the search box
> on http://pear.php.net/ ...
>
> ftp://ftp.rfc-editor.org/in-notes/rfc2045.txt
>
Great, if you found something, can you share the result with us...
On PEAR website, with the mail keyword, I only find this:

Results *1 - 8* of *8*:

   1. *File_IMC <http://pear.php.net/package/File_IMC>*: Create and
      parse Internet Mail Consortium-style files (like vCard and vCalendar)
   2. *Mail <http://pear.php.net/package/Mail>*: Class that provides
      multiple interfaces for sending emails
   3. *Mail_IMAP <http://pear.php.net/package/Mail_IMAP>*: Provides a
      c-client backend for webmail.
   4. *Mail_IMAPv2 <http://pear.php.net/package/Mail_IMAPv2>*: Provides
      a c-client backend for webmail.
   5. *Mail_Mbox <http://pear.php.net/package/Mail_Mbox>*: Read and
      modify Unix MBOXes
   6. *Mail_Mime <http://pear.php.net/package/Mail_Mime>*: The Mail_Mime
      packages allows you to create MIME E-mail messages
   7. *Mail_mimeDecode <http://pear.php.net/package/Mail_mimeDecode>*:
      Provides a class to decode mime messages.
   8. *Mail_Queue <http://pear.php.net/package/Mail_Queue>*: Class for
      put mails in queue and send them later in background.

File_IMC only proceed on vCard an it's no more maintained...

Another idea?

attached mail follows:


Hi Pierre,

I have the same problem: I'm searching a function to parse an email
file. I found this one:

http://pear.php.net/package/Net_IMAP/

I think that you can extract the code you need from the function
getParsedHeaders.

Regards,
 Mauro Lorenzutti

e-mail: mauro.lorenzuttiwebformat.com

---------------------------------------------------------
WEBFORMAT srl | Corte Europa, 12 | I-33097 SPILIMBERGO PN
     Tel +39-0427-926.389 -- Fax +39-0427-927.653
       infowebformat.com -- www.webformat.com
---------------------------------------------------------

attached mail follows:


On 30/01/07, Pierre Pintaric <pierre.pintaricmatrice.com> wrote:
> If somebody uses a great function and want to share, I will please
> him... :-)
>

Er, could you please define "I will please him"?

I think that you've scared off a few potential helpers....

Dotan Cohen

http://lyricslist.com/lyrics/artist_albums/220/gin_blossoms.html
http://rorot.com

attached mail follows:


# pierre.pintaricmatrice.com / 2007-01-30 12:17:01 +0100:
> Roman Neuhauser a écrit :
> >That's probably because you don't know enough about the field to use the
> >right search terms, since PEAR *does* contain a package for parsing email
> >messages, and I have no problems arriving at it from the search box
> >on http://pear.php.net/ ...
> >
> >ftp://ftp.rfc-editor.org/in-notes/rfc2045.txt
>
> Great, if you found something, can you share the result with us...
> On PEAR website, with the mail keyword, I only find this:

You didn't bother looking at the RFC I gave you...

> Results *1 - 8* of *8*:

The results include your desired package.

--
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man. You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991