Re: [PHP] why is (intval('444-44444') == '444-44444') EQUAL??!

2012-06-22 Thread ma...@behnke.biz


Daevid Vincent dae...@daevid.com hat am 22. Juni 2012 um 04:27 geschrieben:

 Huh? Why is this equal??!

http://de2.php.net/manual/en/language.types.type-juggling.php

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



Re: [PHP] why is (intval('444-44444') == '444-44444') EQUAL??!

2012-06-21 Thread Robert Cummings



On 12-06-21 10:27 PM, Daevid Vincent wrote:

Huh? Why is this equal??!

php  $id = '444-4';

php  var_dump($id, intval($id));
string(9) 444-4
int(444)

php  if (intval($id) == $id) echo 'equal'; else echo 'not equal';
equal

or in other words:

php  if (intval('444-4') == '444-4') echo 'equal'; else
echo 'not equal';
equal

I would expect PHP to be evaluating string 444-4 against integer 444
(or string either way)

however, just for giggles, using === works...

php  if ($id === intval($id)) echo 'equal'; else echo 'not equal';
not equal


Using === will always fail because on the left you have a string and on 
the right you have an integer which fails exact comparison based on 
datatype mismatch.


When comparing a string to an integer using == PHP performs type 
juggling and converts the string to an integer first.


Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

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



Re: [PHP] why is (intval('444-44444') == '444-44444') EQUAL??!

2012-06-21 Thread Mike Mackintosh
Using == will compare the two values after type juggling is performed. === will 
compare based on value and type (identical).

PHP Will type juggle the string to an integer.

Your if/else is just like saying: 

php if (444 == 444) echo 'equal'; else echo 'not equal';
equal

-- 
Mike Mackintosh
PHP 5.3 ZCE


On Thursday, June 21, 2012 at 10:27 PM, Daevid Vincent wrote:

 Huh? Why is this equal??!
 
 php  $id = '444-4';
 
 php  var_dump($id, intval($id));
 string(9) 444-4
 int(444)
 
 php  if (intval($id) == $id) echo 'equal'; else echo 'not equal';
 equal
 
 or in other words:
 
 php  if (intval('444-4') == '444-4') echo 'equal'; else
 echo 'not equal';
 equal
 
 I would expect PHP to be evaluating string 444-4 against integer 444
 (or string either way)
 
 however, just for giggles, using === works...
 
 php  if ($id === intval($id)) echo 'equal'; else echo 'not equal';
 not equal
 
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 




Re: [PHP] Why does this script run out of memory?

2011-10-28 Thread Eric Butera
On Fri, Oct 28, 2011 at 12:38 PM, Jim Long p...@umpquanet.com wrote:
 I'm running PHP 5.3.8 on FreeBSD 8.2 with MySQL 5.1.55.

 The script below is designed to be able to WHILE it's way through
 a MySQL query result set, and process each row.

 However, it runs out of memory a little after a quarter million
 rows.  The schema fields total to about 200 bytes per row, so
 the row size doesn't seem very large.

 Why is this running out of memory?

 Thank you!

 Jim

 ?php

 $test_db_host = localhost;
 $test_db_user = foo;
 $test_db_pwd  = bar;
 $test_db_name = farkle;

 $db_host = $test_db_host;
 $db_user = $test_db_user;
 $db_name = $test_db_name;
 $db_pwd  = $test_db_pwd;

 if (!($db_conn = mysql_connect( $db_host, $db_user, $db_pwd )))
        die( Can't connect to MySQL server\n );

 if (!mysql_select_db( $db_name, $db_conn ))
        die( Can't connect to database $db_name\n );

 $qry = select * from test_table order by contract;

 if ($result = mysql_query( $qry, $db_conn )) {

        $n = 0;
        while ($row = mysql_fetch_assoc( $result )) {
 // process row here
                $n++;
        } // while

        mysql_free_result($result);
        echo $n\n;

 } else {

        die( mysql_error() . \n );

 }

 ?


 PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to 
 allocate 20 bytes) in xx3.php on line 24

 Line 24 is:

    24          while ($row = mysql_fetch_assoc( $result )) {


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



Not sure what is happening inside process row here, but I'm sure
that is where your issue is.  Instead of building some giant structure
inside of that while statement you should flush it out to the screen.

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



Re: [PHP] Why does this script run out of memory?

2011-10-28 Thread Jim Long
On Fri, Oct 28, 2011 at 01:21:36PM -0400, Eric Butera wrote:
 On Fri, Oct 28, 2011 at 12:38 PM, Jim Long p...@umpquanet.com wrote:
  I'm running PHP 5.3.8 on FreeBSD 8.2 with MySQL 5.1.55.
 
  The script below is designed to be able to WHILE it's way through
  a MySQL query result set, and process each row.
 
  However, it runs out of memory a little after a quarter million
  rows. ??The schema fields total to about 200 bytes per row, so
  the row size doesn't seem very large.
 
  Why is this running out of memory?
 
  Thank you!
 
  Jim
 
  ?php
 
  $test_db_host = localhost;
  $test_db_user = foo;
  $test_db_pwd ??= bar;
  $test_db_name = farkle;
 
  $db_host = $test_db_host;
  $db_user = $test_db_user;
  $db_name = $test_db_name;
  $db_pwd ??= $test_db_pwd;
 
  if (!($db_conn = mysql_connect( $db_host, $db_user, $db_pwd )))
  ?? ?? ?? ??die( Can't connect to MySQL server\n );
 
  if (!mysql_select_db( $db_name, $db_conn ))
  ?? ?? ?? ??die( Can't connect to database $db_name\n );
 
  $qry = select * from test_table order by contract;
 
  if ($result = mysql_query( $qry, $db_conn )) {
 
  ?? ?? ?? ??$n = 0;
  ?? ?? ?? ??while ($row = mysql_fetch_assoc( $result )) {
  // process row here
  ?? ?? ?? ?? ?? ?? ?? ??$n++;
  ?? ?? ?? ??} // while
 
  ?? ?? ?? ??mysql_free_result($result);
  ?? ?? ?? ??echo $n\n;
 
  } else {
 
  ?? ?? ?? ??die( mysql_error() . \n );
 
  }
 
  ?
 
 
  PHP Fatal error: ??Allowed memory size of 134217728 bytes exhausted (tried 
  to allocate 20 bytes) in xx3.php on line 24
 
  Line 24 is:
 
  ?? ??24 ?? ?? ?? ?? ??while ($row = mysql_fetch_assoc( $result )) {
 
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 
 Not sure what is happening inside process row here, but I'm sure
 that is where your issue is.  Instead of building some giant structure
 inside of that while statement you should flush it out to the screen.

Eric:

Thanks for your reply.

process row here is a comment.  It doesn't do anything.  The
script, exactly as shown, runs out of memory, exactly as shown.

Jim

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



Re: Re: [PHP] Why does this script run out of memory?

2011-10-28 Thread James
 Original Message 
From: Eric Butera eric.but...@gmail.com
To: Jim Long p...@umpquanet.com
Cc: php-general@lists.php.net
Sent: Fri, Oct 28, 2011, 1:22 PM
Subject: Re: [PHP] Why does this script run out of memory?

On Fri, Oct 28, 2011 at 12:38 PM, Jim Long p...@umpquanet.com wrote:
 I'm running PHP 5.3.8 on FreeBSD 8.2 with MySQL 5.1.55.

 The script below is designed to be able to WHILE it's way through
 a MySQL query result set, and process each row.

 However, it runs out of memory a little after a quarter million
 rows.  The schema fields total to about 200 bytes per row, so
 the row size doesn't seem very large.

 Why is this running out of memory?

 Thank you!

 Jim

 ?php

 $test_db_host = localhost;
 $test_db_user = foo;
 $test_db_pwd  = bar;
 $test_db_name = farkle;

 $db_host = $test_db_host;
 $db_user = $test_db_user;
 $db_name = $test_db_name;
 $db_pwd  = $test_db_pwd;

 if (!($db_conn = mysql_connect( $db_host, $db_user, $db_pwd )))
        die( Can't connect to MySQL server\n );

 if (!mysql_select_db( $db_name, $db_conn ))
        die( Can't connect to database $db_name\n );

 $qry = select * from test_table order by contract;

 if ($result = mysql_query( $qry, $db_conn )) {

        $n = 0;
        while ($row = mysql_fetch_assoc( $result )) {
 // process row here
                $n++;
        } // while

        mysql_free_result($result);
        echo $n\n;

 } else {

        die( mysql_error() . \n );

 }

 ?


 PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to 
 allocate 20 bytes) in xx3.php on line 24

 Line 24 is:

    24          while ($row = mysql_fetch_assoc( $result )) {


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



Not sure what is happening inside process row here, but I'm sure
that is where your issue is.  Instead of building some giant structure
inside of that while statement you should flush it out to the screen.

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

Try unsetting the $row variable, you may be fetching extremely large rows but 
that's a big if, because your script is allowed to allocate 128MB of memory 
before puking. Are you dealing with very large data sets from the database? If 
you are dealing with large data sets, then try redefining your query.




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



Re: Re: [PHP] Why does this script run out of memory?

2011-10-28 Thread Ashley Sheridan
On Fri, 2011-10-28 at 13:32 -0400, James wrote:

  Original Message 
 From: Eric Butera eric.but...@gmail.com
 To: Jim Long p...@umpquanet.com
 Cc: php-general@lists.php.net
 Sent: Fri, Oct 28, 2011, 1:22 PM
 Subject: Re: [PHP] Why does this script run out of memory?
 
 On Fri, Oct 28, 2011 at 12:38 PM, Jim Long p...@umpquanet.com wrote:
  I'm running PHP 5.3.8 on FreeBSD 8.2 with MySQL 5.1.55.
 
  The script below is designed to be able to WHILE it's way through
  a MySQL query result set, and process each row.
 
  However, it runs out of memory a little after a quarter million
  rows.  The schema fields total to about 200 bytes per row, so
  the row size doesn't seem very large.
 
  Why is this running out of memory?
 
  Thank you!
 
  Jim
 
  ?php
 
  $test_db_host = localhost;
  $test_db_user = foo;
  $test_db_pwd  = bar;
  $test_db_name = farkle;
 
  $db_host = $test_db_host;
  $db_user = $test_db_user;
  $db_name = $test_db_name;
  $db_pwd  = $test_db_pwd;
 
  if (!($db_conn = mysql_connect( $db_host, $db_user, $db_pwd )))
 die( Can't connect to MySQL server\n );
 
  if (!mysql_select_db( $db_name, $db_conn ))
 die( Can't connect to database $db_name\n );
 
  $qry = select * from test_table order by contract;
 
  if ($result = mysql_query( $qry, $db_conn )) {
 
 $n = 0;
 while ($row = mysql_fetch_assoc( $result )) {
  // process row here
 $n++;
 } // while
 
 mysql_free_result($result);
 echo $n\n;
 
  } else {
 
 die( mysql_error() . \n );
 
  }
 
  ?
 
 
  PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried 
  to allocate 20 bytes) in xx3.php on line 24
 
  Line 24 is:
 
 24  while ($row = mysql_fetch_assoc( $result )) {
 
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 
 Not sure what is happening inside process row here, but I'm sure
 that is where your issue is.  Instead of building some giant structure
 inside of that while statement you should flush it out to the screen.
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 Try unsetting the $row variable, you may be fetching extremely large rows but 
 that's a big if, because your script is allowed to allocate 128MB of memory 
 before puking. Are you dealing with very large data sets from the database? 
 If you are dealing with large data sets, then try redefining your query.
 
 
 
 


I don't think that will help, as it gets reset each time it iterates the
loop when it's given a new value.

Have you tried narrowing down your query to only the fields that you
need in your script? Instead of SELECT * FROM test_table try something
like SELECT field1, field2, etc FROM test_table

Another thing to try is running this in over the command line if you
can. I've had a lot of success with memory intensive scripts like this.
Although it may not help in your specific case, it's worth noting at
least.

-- 
Thanks,
Ash
http://www.ashleysheridan.co.uk




Re: Re: [PHP] Why does this script run out of memory?

2011-10-28 Thread Jim Long
On Fri, Oct 28, 2011 at 01:32:32PM -0400, James wrote:
 
 On Fri, Oct 28, 2011 at 12:38 PM, Jim Long p...@umpquanet.com wrote:
  I'm running PHP 5.3.8 on FreeBSD 8.2 with MySQL 5.1.55.
 
  The script below is designed to be able to WHILE it's way through
  a MySQL query result set, and process each row.
 
  However, it runs out of memory a little after a quarter million
  rows. ??The schema fields total to about 200 bytes per row, so
  the row size doesn't seem very large.
 
  Why is this running out of memory?
 
  Thank you!
 
  Jim
 
  ?php
 
  $test_db_host = localhost;
  $test_db_user = foo;
  $test_db_pwd ??= bar;
  $test_db_name = farkle;
 
  $db_host = $test_db_host;
  $db_user = $test_db_user;
  $db_name = $test_db_name;
  $db_pwd ??= $test_db_pwd;
 
  if (!($db_conn = mysql_connect( $db_host, $db_user, $db_pwd )))
  ?? ?? ?? ??die( Can't connect to MySQL server\n );
 
  if (!mysql_select_db( $db_name, $db_conn ))
  ?? ?? ?? ??die( Can't connect to database $db_name\n );
 
  $qry = select * from test_table order by contract;
 
  if ($result = mysql_query( $qry, $db_conn )) {
 
  ?? ?? ?? ??$n = 0;
  ?? ?? ?? ??while ($row = mysql_fetch_assoc( $result )) {
  // process row here
  ?? ?? ?? ?? ?? ?? ?? ??$n++;
  ?? ?? ?? ??} // while
 
  ?? ?? ?? ??mysql_free_result($result);
  ?? ?? ?? ??echo $n\n;
 
  } else {
 
  ?? ?? ?? ??die( mysql_error() . \n );
 
  }
 
  ?
 
 
  PHP Fatal error: ??Allowed memory size of 134217728 bytes exhausted (tried 
  to allocate 20 bytes) in xx3.php on line 24
 
  Line 24 is:
 
  ?? ??24 ?? ?? ?? ?? ??while ($row = mysql_fetch_assoc( $result )) {
 
 
 Not sure what is happening inside process row here, but I'm sure
 that is where your issue is.  Instead of building some giant structure
 inside of that while statement you should flush it out to the screen.
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 Try unsetting the $row variable, you may be fetching extremely
 large rows but that's a big if, because your script is allowed to
 allocate 128MB of memory before puking. Are you dealing with very
 large data sets from the database? If you are dealing with large
 data sets, then try redefining your query.

James:

Thanks for taking time to help.

The row size is small by my standards (see below).  The query result
has just under 300,000 records, and it's puking about 90% of the way
through.

Changing the while loop to:

while ($row = mysql_fetch_assoc( $result )) {
$n++;
echo sprintf( %7d %12d\n, $n, memory_get_peak_usage() );
} // while

the tail end of the output becomes:

 274695134203084
 274696134203524
 274697134203964
PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to 
allocate 240 bytes) in xx3.php on line 26

Changing the while loop further to:

while ($row = mysql_fetch_assoc( $result )) {
unset( $row );
$n++;
echo sprintf( %7d %12d\n, $n, memory_get_peak_usage() );
} // while

the tail end of the output becomes:

 274695134202232
 274696134202672
 274697134203112
 274698134203552
 274699134203992
PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to 
allocate 240 bytes) in xx3.php on line 27

So it does get a little farther through the dataset, but not much.

Jim


mysql describe test_table;
+--+-+--+-+-+---+
| Field| Type| Null | Key | Default | Extra |
+--+-+--+-+-+---+
| contract | int(11) | YES  | | NULL|   |
| A| int(8) unsigned | NO   | | 0   |   |
| B| datetime| YES  | | NULL|   |
| C| int(8) unsigned | YES  | | 0   |   |
| D| char(8) | YES  | | NULL|   |
| E| char(8) | YES  | | |   |
| F| int(4)  | YES  | | 0   |   |
| G| int(1)  | YES  | | 0   |   |
| H| char(8) | YES  | | 00:00   |   |
| I| varchar(100)| YES  | | XXX |   |
+--+-+--+-+-+---+
10 rows in set (0.00 sec)


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



Re: [PHP] Why does this script run out of memory?

2011-10-28 Thread Jim Giner
If all you want to do is count the records, why are you not letting sql do 
it for you instead of doing the while loop?  That's all that script is 
doing, if that is the exact code you ran. 



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



Re: Re: [PHP] Why does this script run out of memory?

2011-10-28 Thread Daniel Brown
On Fri, Oct 28, 2011 at 14:05, Jim Long p...@umpquanet.com wrote:

 the tail end of the output becomes:

  274695    134202232
  274696    134202672
  274697    134203112
  274698    134203552
  274699    134203992
 PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to 
 allocate 240 bytes) in xx3.php on line 27

Each row increases memory allocation by 440 bytes.  274,700 rows
would equal 120,868,000 bytes of MySQL data in the buffer.
Subtracting the 240 bytes from the 440 anticipated in the 274,700th
row, that means the memory footprint of your script in execution
(including PHP and its extensions, Apache, the MySQL connection, et
cetera) is utilizing 13,349,928 (roughly 13.4MB), which is pretty
average, depending on the configuration and bloat of the builds you're
using.

Ways around this: increase memory allocation and risk bogging-down
your machine, or use mysql_unbuffered_query().

-- 
/Daniel P. Brown
Network Infrastructure Manager
http://www.php.net/

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



Re: [PHP] Why does this script run out of memory?

2011-10-28 Thread Daniel Brown
On Fri, Oct 28, 2011 at 13:25, Jim Long p...@umpquanet.com wrote:

 Eric:

 Thanks for your reply.

 process row here is a comment.  It doesn't do anything.  The
 script, exactly as shown, runs out of memory, exactly as shown.

My response presumes that you're planning on placing something
into this comment area, in which the memory will only further
increase.  If *presumed* should be replaced by *ASSumed* in this case,
skip mysql_unbuffered_query() and go straight for mysql_num_rows().
Do not pass GO.  Do not collect $200.

-- 
/Daniel P. Brown
Network Infrastructure Manager
http://www.php.net/

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



Re: [PHP] Why does this script run out of memory?

2011-10-28 Thread Jim Long
On Fri, Oct 28, 2011 at 03:24:37PM -0400, Jim Giner wrote:
 If all you want to do is count the records, why are you not letting sql do 
 it for you instead of doing the while loop?  That's all that script is 
 doing, if that is the exact code you ran. 

Hi, Jim.

Thank you for replying.

One of the key concepts of troubleshooting is that when you
encounter a problem, you try to state the problem with as simple
a test case as possible, so that testing will not be complicated
by extraneous variables or code that may or may not have any
impact on the problem.

I don't want to just count the records, I want to get some work
done for a client.  That work involves processing every record in
the result set.  Counting is just a simple process to conduct
for the purpose of debugging this loop algorithm.

The problem is that this algorithm fails to process all the
records in the result set.

I appreciate any insights you have as to why that is happening.

Jim


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



Re: [PHP] Why does this script run out of memory?

2011-10-28 Thread Eric Butera
On Fri, Oct 28, 2011 at 3:29 PM, Daniel Brown danbr...@php.net wrote:
 On Fri, Oct 28, 2011 at 13:25, Jim Long p...@umpquanet.com wrote:

 Eric:

 Thanks for your reply.

 process row here is a comment.  It doesn't do anything.  The
 script, exactly as shown, runs out of memory, exactly as shown.

    My response presumes that you're planning on placing something
 into this comment area, in which the memory will only further
 increase.  If *presumed* should be replaced by *ASSumed* in this case,
 skip mysql_unbuffered_query() and go straight for mysql_num_rows().
 Do not pass GO.  Do not collect $200.

 --
 /Daniel P. Brown
 Network Infrastructure Manager
 http://www.php.net/


I was glad to learn what comments were.

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



Re: [PHP] Why does this script run out of memory?

2011-10-28 Thread Daniel Brown
On Fri, Oct 28, 2011 at 16:21, Jim Long p...@umpquanet.com wrote:

 I will try experimenting with Daniel's idea of unbuffered
 queries, but my understanding is that while an unbuffered result
 resource is in use, no other SQL transactions can be conducted.
 Maybe I can get around that by using one MySQL connection for the
 unbuffered query, and another separate MySQL connection for the
 incidental SQL queries that I need to perform as I process each
 record from the large dataset.

Just for the sake of a kick-start, you could throw together a
simple class and then call that quite easily.

-- 
/Daniel P. Brown
Network Infrastructure Manager
http://www.php.net/

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



Re: [PHP] Why does this script run out of memory?

2011-10-28 Thread Jim Long
On Fri, Oct 28, 2011 at 03:42:48PM -0400, Eric Butera wrote:
 On Fri, Oct 28, 2011 at 3:29 PM, Daniel Brown danbr...@php.net wrote:
  On Fri, Oct 28, 2011 at 13:25, Jim Long p...@umpquanet.com wrote:
 
  Eric:
 
  Thanks for your reply.
 
  process row here is a comment. ??It doesn't do anything. ??The
  script, exactly as shown, runs out of memory, exactly as shown.
 
  ?? ??My response presumes that you're planning on placing something
  into this comment area, in which the memory will only further
  increase. ??If *presumed* should be replaced by *ASSumed* in this case,
  skip mysql_unbuffered_query() and go straight for mysql_num_rows().
  Do not pass GO. ??Do not collect $200.
 
  --
  /Daniel P. Brown
  Network Infrastructure Manager
  http://www.php.net/
 
 
 I was glad to learn what comments were.

Eric: Please forgive me if I was curt in my message to you.  I
don't mean to bite the hands that are trying to help.  As Daniel
rightly observed, my concern is just that if a pretty much empty
while loop runs out of memory when trying to step through each
record, I'm really going to be hosed if I try to start doing some
productive work within the while loop.

Daniel's memory trend analysis is helpful.  I'm testing from the
command line, so there's no Apache overhead, but the memory usage
starts as:

  1 12145496
  2 12145976
  3 12146408
  4 12146804
  5 12147200
  6 12147596
...

I normally prefer to work in PostgreSQL, but the client has already
gone down the MySQL road.  Just for edification's sake, I exported
the table in PostgreSQL and re-worked my code:

if (!($db_conn = pg_connect( host=$db_host user=$db_user dbname=$db_name 
password=$db_pwd )))
die( Can't connect to SQL server\n );

$qry = select * from test_table order by contract;

if ($result = pg_query( $db_conn, $qry )) {

$n = 0;
while ($row = pg_fetch_assoc( $result )) {
unset( $row );
$n++;
echo sprintf( %7d %12d\n, $n, memory_get_peak_usage() );
} // while

pg_free_result($result);
echo $n\n;

} else {

die( pg_last_error() . \n );

}

Using PostgreSQL (on a completely different machine), this runs
to completion, and memory consumption is nearly flat:

  1   329412
  2   329724
  3   329796
  4   329796
  5   329796
...
 295283   329860
 295284   329860
 295285   329860
 295286   329860
 295287   329860
295287

If one were to describe the memory consumption as a 'leak', then
PostgreSQL is leaking at a much slower rate than MySQL.  Postgres
leaks as much over the entire run (329860-329412=448) as MySQL
does on each row.  Put another way, the MySQL version leaks
memory almost 300,000 times faster.

My PostgreSQL machine also has MySQL installed, so I ran the
MySQL version of the code on that machine for testing, a second
opinion if you like.  It leaked memory almost as bad as my
client's PHP/MySQL installation, but a little more slowly, 396
bytes or so per row.  The slower memory consumption enabled the
code to run to completion, barely:

  1 12149492
  2 12149972
  3 12150404
  4 12150800
...
 295284129087704
 295285129088100
 295286129088496
 295287129088892
295287

So is this just a difference in the programming quality of the 
database extensions for MySQL vs. PostgreSQL that one gobbles up
memory profusely, while the other one has only a slight, slow
leak?

I will try experimenting with Daniel's idea of unbuffered
queries, but my understanding is that while an unbuffered result
resource is in use, no other SQL transactions can be conducted.
Maybe I can get around that by using one MySQL connection for the
unbuffered query, and another separate MySQL connection for the
incidental SQL queries that I need to perform as I process each
record from the large dataset.

Jim

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



Re: [PHP] Why does this script run out of memory?

2011-10-28 Thread Tommy Pham
On Fri, Oct 28, 2011 at 9:38 AM, Jim Long p...@umpquanet.com wrote:

 I'm running PHP 5.3.8 on FreeBSD 8.2 with MySQL 5.1.55.


Jim,

Installed from packages or standard port tree build?  Did you do any tweak
for the ports build?  Any special compiler parameters in your make.conf?
I've noticed that you used MySQL extensions.  Have you tried MySQLi to see
if there's any difference?

Regards,
Tommy


Re: [PHP] Why does this script run out of memory?

2011-10-28 Thread Paul Halliday
On Fri, Oct 28, 2011 at 1:38 PM, Jim Long p...@umpquanet.com wrote:
 I'm running PHP 5.3.8 on FreeBSD 8.2 with MySQL 5.1.55.

 The script below is designed to be able to WHILE it's way through
 a MySQL query result set, and process each row.

 However, it runs out of memory a little after a quarter million
 rows.  The schema fields total to about 200 bytes per row, so
 the row size doesn't seem very large.

 Why is this running out of memory?

 Thank you!

 Jim

 ?php

 $test_db_host = localhost;
 $test_db_user = foo;
 $test_db_pwd  = bar;
 $test_db_name = farkle;

 $db_host = $test_db_host;
 $db_user = $test_db_user;
 $db_name = $test_db_name;
 $db_pwd  = $test_db_pwd;

 if (!($db_conn = mysql_connect( $db_host, $db_user, $db_pwd )))
        die( Can't connect to MySQL server\n );

 if (!mysql_select_db( $db_name, $db_conn ))
        die( Can't connect to database $db_name\n );

 $qry = select * from test_table order by contract;

 if ($result = mysql_query( $qry, $db_conn )) {

        $n = 0;
        while ($row = mysql_fetch_assoc( $result )) {
 // process row here
                $n++;
        } // while


Whats the difference between fetch_assoc and fetch_row?

I use:
while ($row = mysql_fetch_row($theQuery)) {
doCartwheel;
}

on just under 300 million rows and nothing craps out. I have
memory_limit set to 4GB though. Although, IIRC I pushed it up for GD
not mysql issues.

Same OS and php ver, MySQL is 5.1.48

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



[PHP] mysql_fetch_array() vs mysql_fetch_assoc() WAS: Re: [PHP] Why does this script run out of memory?

2011-10-28 Thread Daniel Brown
On Fri, Oct 28, 2011 at 18:13, Paul Halliday paul.halli...@gmail.com wrote:

 Whats the difference between fetch_assoc and fetch_row?

 I use:
 while ($row = mysql_fetch_row($theQuery)) {
    doCartwheel;
 }

 on just under 300 million rows and nothing craps out. I have
 memory_limit set to 4GB though. Although, IIRC I pushed it up for GD
 not mysql issues.

 Same OS and php ver, MySQL is 5.1.48

Please don't hijack other's threads to ask a question.  I've
started this as a new thread to address this question.

mysql_fetch_array() grabs all of the data and places it in a
simple numerically-keyed array.

By contrast, mysql_fetch_assoc() grabs it and populates an
associative array.  This means that the column names (or aliases, et
cetera) become the keys for the array.  With mysql_fetch_assoc(), you
can still call an array key by number, but it's not vice-versa with
mysql_fetch_array().

The difference in overhead, if you meant that (in which case, my
apologies for reading it as a question of functional difference), is
variable: it's based mainly on the difference between the bytes
representing the integers used as keys in mysql_fetch_array() versus
the size in bytes of the strings used as keys in mysql_fetch_assoc().

-- 
/Daniel P. Brown
Network Infrastructure Manager
http://www.php.net/

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



Re: [PHP] Why does this script run out of memory?

2011-10-28 Thread Jim Long
On Fri, Oct 28, 2011 at 02:57:02PM -0700, Tommy Pham wrote:
 On Fri, Oct 28, 2011 at 9:38 AM, Jim Long p...@umpquanet.com wrote:
 
  I'm running PHP 5.3.8 on FreeBSD 8.2 with MySQL 5.1.55.
 
 
 Jim,
 
 Installed from packages or standard port tree build?  Did you do any tweak
 for the ports build?  Any special compiler parameters in your make.conf?
 I've noticed that you used MySQL extensions.  Have you tried MySQLi to see
 if there's any difference?
 
 Regards,
 Tommy

MySQL server and PHP and extensions built from ports, without any
local tweaks.  Nothing very interesting in /etc/make.conf:

MASTER_SITE_FREEBSD=1
CPUTYPE?=p3
USA_RESIDENT=YES
NO_INET6=YES
WITHOUT_IPV6=YES
NO_I4B=true
NO_BLUETOOTH=true
NO_IPFILTER=true
NO_KERBEROS=true
NO_ATM=true # do not build ATM related programs and libraries
NOUUCP=true # do not build uucp related programs
NO_UUCP=true # do not build uucp related programs
NO_GAMES=true
NO_PROFILE=true
PERL_VERSION=5.10.1

Port options for php5-extensions are:

_OPTIONS_READ=php5-extensions-1.5
WITH_BCMATH=true
WITHOUT_BZ2=true
WITHOUT_CALENDAR=true
WITH_CTYPE=true
WITHOUT_CURL=true
WITHOUT_DBA=true
WITH_DOM=true
WITHOUT_EXIF=true
WITH_FILEINFO=true
WITH_FILTER=true
WITHOUT_FRIBIDI=true
WITH_FTP=true
WITHOUT_GD=true
WITHOUT_GETTEXT=true
WITHOUT_GMP=true
WITH_HASH=true
WITHOUT_ICONV=true
WITHOUT_IMAP=true
WITHOUT_INTERBASE=true
WITH_JSON=true
WITHOUT_LDAP=true
WITHOUT_MBSTRING=true
WITHOUT_MCRYPT=true
WITHOUT_MSSQL=true
WITH_MYSQL=true
WITHOUT_MYSQLI=true
WITHOUT_ODBC=true
WITHOUT_OPENSSL=true
WITHOUT_PCNTL=true
WITH_PDF=true
WITH_PDO=true
WITHOUT_PDO_SQLITE=true
WITH_PGSQL=true
WITH_POSIX=true
WITHOUT_PSPELL=true
WITHOUT_READLINE=true
WITHOUT_RECODE=true
WITH_SESSION=true
WITHOUT_SHMOP=true
WITH_SIMPLEXML=true
WITHOUT_SNMP=true
WITHOUT_SOAP=true
WITHOUT_SOCKETS=true
WITHOUT_SQLITE=true
WITHOUT_SQLITE3=true
WITHOUT_SYBASE_CT=true
WITHOUT_SYSVMSG=true
WITHOUT_SYSVSEM=true
WITHOUT_SYSVSHM=true
WITHOUT_TIDY=true
WITH_TOKENIZER=true
WITHOUT_WDDX=true
WITH_XML=true
WITH_XMLREADER=true
WITHOUT_XMLRPC=true
WITH_XMLWRITER=true
WITHOUT_XSL=true
WITHOUT_YAZ=true
WITHOUT_ZIP=true
WITHOUT_ZLIB=true

As Daniel suggested, using mysql_query_unbuffered works a treat,
at the expense of a small amount of additional programming
complexity.  In my prior work with Postgres, I found that it
would handle small or large datasets with equal ease, so I was
surprised to find that MySQL blew up given a sufficient number of
repeated calls to mysql_fetch_row();

Thank you for mentioning MySQLi.  Although it is alphabetically
adjacent in the documentation, it had never drawn my attention.
I'll build the PHP extension and take a look when time permits.

Jim

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



[PHP] Re: mysql_fetch_array() vs mysql_fetch_assoc() WAS: Re: [PHP] Why does this script run out of memory?

2011-10-28 Thread Paul Halliday
On Fri, Oct 28, 2011 at 7:19 PM, Daniel Brown danbr...@php.net wrote:
 On Fri, Oct 28, 2011 at 18:13, Paul Halliday paul.halli...@gmail.com wrote:

 Whats the difference between fetch_assoc and fetch_row?

 I use:
 while ($row = mysql_fetch_row($theQuery)) {
    doCartwheel;
 }

 on just under 300 million rows and nothing craps out. I have
 memory_limit set to 4GB though. Although, IIRC I pushed it up for GD
 not mysql issues.

 Same OS and php ver, MySQL is 5.1.48

    Please don't hijack other's threads to ask a question.  I've
 started this as a new thread to address this question.

    mysql_fetch_array() grabs all of the data and places it in a
 simple numerically-keyed array.

    By contrast, mysql_fetch_assoc() grabs it and populates an
 associative array.  This means that the column names (or aliases, et
 cetera) become the keys for the array.  With mysql_fetch_assoc(), you
 can still call an array key by number, but it's not vice-versa with
 mysql_fetch_array().

    The difference in overhead, if you meant that (in which case, my
 apologies for reading it as a question of functional difference), is
 variable: it's based mainly on the difference between the bytes
 representing the integers used as keys in mysql_fetch_array() versus
 the size in bytes of the strings used as keys in mysql_fetch_assoc().

 --
 /Daniel P. Brown
 Network Infrastructure Manager
 http://www.php.net/


Sorry.

I was just throwing it out there with the hope that there might be a
tidbit that would help the OP.

I have a simliar setup and I can query far more than a 1/4 million
rows. What I offered is what I am doing differently.


-- 
Paul Halliday
http://www.squertproject.org/

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



Re: [PHP] mysql_fetch_array() vs mysql_fetch_assoc() WAS: Re: [PHP] Why does this script run out of memory?

2011-10-28 Thread Jim Long
On Fri, Oct 28, 2011 at 06:19:56PM -0400, Daniel Brown wrote:
 On Fri, Oct 28, 2011 at 18:13, Paul Halliday paul.halli...@gmail.com wrote:
 
  Whats the difference between fetch_assoc and fetch_row?
 
  I use:
  while ($row = mysql_fetch_row($theQuery)) {
  ? ?doCartwheel;
  }
 
  on just under 300 million rows and nothing craps out. I have
  memory_limit set to 4GB though. Although, IIRC I pushed it up for GD
  not mysql issues.
 
  Same OS and php ver, MySQL is 5.1.48
 
 Please don't hijack other's threads to ask a question.  I've
 started this as a new thread to address this question.
 
 mysql_fetch_array() grabs all of the data and places it in a
 simple numerically-keyed array.
 
 By contrast, mysql_fetch_assoc() grabs it and populates an
 associative array.  This means that the column names (or aliases, et
 cetera) become the keys for the array.  With mysql_fetch_assoc(), you
 can still call an array key by number, but it's not vice-versa with
 mysql_fetch_array().

I'm not seeing any numeric keys in my mysql_fetch_assoc() arrays.

However, mysql_fetch_row (by default) does both: the array will be
indexed numerically from 0 to N-1 corresponding to the table's N
columns, and the array will also have string key indices which
correspond to the query's column names.  So by default,
mysql_fetch_row uses twice the amount of data, because each field
appears in the array twice.

var_dump( $row ) will show in graphic detail.


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



Re: [PHP] mysql_fetch_array() vs mysql_fetch_assoc() WAS: Re: [PHP] Why does this script run out of memory?

2011-10-28 Thread Daniel Brown
On Fri, Oct 28, 2011 at 18:48, Jim Long p...@umpquanet.com wrote:

 I'm not seeing any numeric keys in my mysql_fetch_assoc() arrays.

You're absolutely correct, that's my mistake: substitute
mysql_fetch_row() for mysql_fetch_assoc().  Duh.

Time to call it a week

-- 
/Daniel P. Brown
Network Infrastructure Manager
http://www.php.net/

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



Re: [PHP] Why does this script run out of memory?

2011-10-28 Thread shiplu
I had a spider written in PHP long ago. I had similar problems.
because there were millions of rows of urls and I was fetching them in
one single query. See inline, could this modification help you. Please
test.

On Fri, Oct 28, 2011 at 10:38 PM, Jim Long p...@umpquanet.com wrote:

 I'm running PHP 5.3.8 on FreeBSD 8.2 with MySQL 5.1.55.

 The script below is designed to be able to WHILE it's way through
 a MySQL query result set, and process each row.

 However, it runs out of memory a little after a quarter million
 rows.  The schema fields total to about 200 bytes per row, so
 the row size doesn't seem very large.

 Why is this running out of memory?

 Thank you!

 Jim

 ?php

 $test_db_host = localhost;
 $test_db_user = foo;
 $test_db_pwd  = bar;
 $test_db_name = farkle;

 $db_host = $test_db_host;
 $db_user = $test_db_user;
 $db_name = $test_db_name;
 $db_pwd  = $test_db_pwd;

 if (!($db_conn = mysql_connect( $db_host, $db_user, $db_pwd )))
        die( Can't connect to MySQL server\n );

 if (!mysql_select_db( $db_name, $db_conn ))
        die( Can't connect to database $db_name\n );

$limit=10;
$offset=0;
while(1){
 $qry = select * from test_table order by contract $offset, $limit;

 if ($result = mysql_query( $qry, $db_conn )) {

        $n = 0;
        while ($row = mysql_fetch_assoc( $result )) {
 // process row here
                $n++;
        } // while

        mysql_free_result($result);
        echo $n\n;

 } else {

        die( mysql_error() . \n );
// break the loop
break;

 }
$offset+=$limit;
}
 ?



Its the same thing but you are fetching data in chunks.

Now this portion order by contract on quarter million rows is not a
good practice. It will slow down your query time and make the script
severely slow.
I had about 100 millions of rows in my table in the url and I was
sorting on last-visit column. Later I removed the order by and it was
much faster.

Try it and let us know.

Thanks


--
Shiplu Mokadd.im
Follow me, http://twitter.com/shiplu
Innovation distinguishes between follower and leader

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



Re: [PHP] Why count() returns no error when string is given ?

2011-08-16 Thread Florian Lemaitre

Le 16/08/2011 16:29, rs...@live.com a écrit :

For example when I do:

   strlen(array(1,2,3));

php shows: Warning: strlen() expects parameter 1 to be string, array
given in...

but when I do:

   count('string');

It simply returns 1 like nothing happened. I would expect such
behavior if I write:

   count((array)'string')

but otherwise such behavior is very misleading and inconsistent.



manual : function.count.php

Returns the number of elements in/var/. If/var/is not an array or an 
object with implementedCountable 
http://www.php.net/manual/en/class.countable.phpinterface,/1/will be 
returned. There is one exception, if/var/is*NULL*,/0/will be returned.


Re: [PHP] Why count() returns no error when string is given ?

2011-08-16 Thread Florian Lemaitre

Le 16/08/2011 16:32, Florian Lemaitre a écrit :

Le 16/08/2011 16:29, rs...@live.com a écrit :

For example when I do:

   strlen(array(1,2,3));

php shows: Warning: strlen() expects parameter 1 to be string, array
given in...

but when I do:

   count('string');

It simply returns 1 like nothing happened. I would expect such
behavior if I write:

   count((array)'string')

but otherwise such behavior is very misleading and inconsistent.



manual : function.count.php

Returns the number of elements in/var/. If/var/is not an array or an 
object with implementedCountable 
http://www.php.net/manual/en/class.countable.phpinterface,/1/will be 
returned. There is one exception, if/var/is*NULL*,/0/will be returned.



Oups...
Returns the number of elements in var. If var is not an array or an 
object with implemented Countable interface, 1 will be returned. There 
is one exception, if var is NULL, 0 will be returned.



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



Re: [PHP] Why count() returns no error when string is given ?

2011-08-16 Thread rsk82
Hello Florian,

Tuesday, August 16, 2011, 4:32:39 PM, you wrote:

 manual : function.count.php

 Returns the number of elements in/var/. If/var/is not an array or an 
 object with implementedCountable 
 http://www.php.net/manual/en/class.countable.phpinterface,/1/will be
 returned. There is one exception, if/var/is*NULL*,/0/will be returned.

Yes I know, but I wonder what is the master reason behind this line of
doing things ?

The fact that something is documented shoudn't make it automatically
right. Are there scripts where people are putting strings into count
by purpose, not by an accident ? Is this behavior having some grand
purpose behind id, or is it just a historical accident for early days
of php ?


-- 
Best regards,
 rsk82mailto:rs...@live.com


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



Re: [PHP] Why count() returns no error when string is given ?

2011-08-16 Thread Florian Lemaitre

Le 16/08/2011 16:50, rs...@live.com a écrit :

Hello Florian,

Tuesday, August 16, 2011, 4:32:39 PM, you wrote:


manual : function.count.php
Returns the number of elements in/var/. If/var/is not an array or an
object with implementedCountable
http://www.php.net/manual/en/class.countable.phpinterface,/1/will be
returned. There is one exception, if/var/is*NULL*,/0/will be returned.

Yes I know, but I wonder what is the master reason behind this line of
doing things ?

The fact that something is documented shoudn't make it automatically
right. Are there scripts where people are putting strings into count
by purpose, not by an accident ? Is this behavior having some grand
purpose behind id, or is it just a historical accident for early days
of php ?



this question has already been discussed 8 days ago in this mailing list.
You can see the archive here :
http://www.mail-archive.com/php-general@lists.php.net/msg267800.html


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



Re: [PHP] Why Constants could Not be Array?

2011-04-30 Thread Stuart Dallas
On Saturday, 30 April 2011 at 10:51, Walkinraven wrote:
For needing a constants=array, I have to use
 'public static $a = array(...)'
 
 instead.
 
 Why the language could not relax the restriction of constants?

As I understand it constants must be declarations not evaluations because 
they're initialised during parsing not execution. Arrays are evaluations even 
if they only contain literal values. It could be done, but it would require a 
fundamental change to the engine and the benefit-cost calculation just doesn't 
add up.

-Stuart

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






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



Re: [PHP] Why Constants could Not be Array?

2011-04-30 Thread Andre Polykanine
Hello Walkinraven,

I use serialize for that.
define(MY_CONSTANT, serialize(array(1, 2, hello)));

-- 
With best regards from Ukraine,
Andre
Skype: Francophile
My blog: http://oire.org/menelion (mostly in Russian)
Twitter: http://twitter.com/m_elensule
Facebook: http://facebook.com/menelion

 Original message 
From: Walkinraven walkinra...@gmail.com
To: php-general@lists.php.net
Date created: , 12:51:15 PM
Subject: [PHP] Why Constants could Not be Array?


  For needing a constants=array, I have to use
'public static $a = array(...)'

instead.

Why the language could not relax the restriction of constants?

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



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



Re: [PHP] Why Constants could Not be Array?

2011-04-30 Thread Stuart Dallas
On Saturday, 30 April 2011 at 17:52, Andre Polykanine wrote:
Hello Walkinraven,
 
 I use serialize for that.
 define(MY_CONSTANT, serialize(array(1, 2, hello)));
 
 -- 
 With best regards from Ukraine,
 Andre
 Skype: Francophile
 My blog: http://oire.org/menelion (mostly in Russian)
 Twitter: http://twitter.com/m_elensule
 Facebook: http://facebook.com/menelion

That's not a class constant. That type of constant is not defined until that 
line is executed (so an array is a valid value), whereas class constants are 
declared when the file is parsed.

-Stuart

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


  Original message 
 From: Walkinraven walkinra...@gmail.com
 To: php-general@lists.php.net
 Date created: , 12:51:15 PM
 Subject: [PHP] Why Constants could Not be Array?
 
 
  For needing a constants=array, I have to use
 'public static $a = array(...)'
 
 instead.
 
 Why the language could not relax the restriction of constants?
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 


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



Re: [PHP] Why is this array_walk_recursive action not working? [SOLVED]

2011-02-25 Thread Dave M G
Feln, Richard, Jim,

Thank you for responding.

I understand now that the problem wasn't with variable scope, but with
my lack of understanding of what array_walk_recursive returns.

Thank you all for your explanations.

-- 
Dave M G

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



Re: [PHP] Why is this array_walk_recursive action not working?

2011-02-24 Thread FeIn
Hi,

How does the input array look like (the contents of the $karamohArray
variable) ? Is your script generating any errors? What do you expect to
happen when you call array_walk_recursive?

On Thu, Feb 24, 2011 at 1:01 PM, Dave M G mar...@autotelic.com wrote:

 PHP users,

 I obviously don't understand what array_walk_recursive does.

 Can someone break down in simple terms why the following doesn't work?

 - - -

 $karamohOutput['test'] = ;

 function test_print($item, $key)
 {
return $key holds $item\n;
 }
 $karamohOutput['test'] .= array_walk_recursive($karamohArray,
 'test_print');

 - - -

 Any advice would be much appreciated.

 --
 Dave M G

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




Re: [PHP] Why is this array_walk_recursive action not working?

2011-02-24 Thread Dave M G
FeIn,

Thank you for responding.


 what did you expect to happen when you call array_walk_recursive?


What I don't understand is why it did not append to the string as it
walked through each key/value pair.

It seems like even though the variable inside the function called by
array_walk_recursive has the same name as a global variable, it gets
treated as if it only has local scope and nothing done to it applies to
the global variable.

-- 
Dave M G

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



Re: [PHP] Why is this array_walk_recursive action not working?

2011-02-24 Thread FeIn
Hi,

Well, first array_walk_recursive returns a boolean so what you are doing in
you script is append a boolean (true or false) that will be converted to
string. So if array_walk_recursive will return true you will have the string
1 in $karamohOutput['test'], and if array_walk_recursive will return false
you will have the empty string  in $karamohOutput['test'].

I think what you're after is this:

$karamohOutput['test'] = ;

foreach ( new RecursiveIteratorIterator( new RecursiveArrayIterator(
$karamohArray ) ) as $key = $item ) {
$karamohOutput['test'] .= $key holds $item\n;
}

On Thu, Feb 24, 2011 at 5:15 PM, Dave M G mar...@autotelic.com wrote:

 FeIn,

 Thank you for responding.


  what did you expect to happen when you call array_walk_recursive?


 What I don't understand is why it did not append to the string as it
 walked through each key/value pair.

 It seems like even though the variable inside the function called by
 array_walk_recursive has the same name as a global variable, it gets
 treated as if it only has local scope and nothing done to it applies to
 the global variable.

 --
 Dave M G

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




Re: [PHP] Why is this array_walk_recursive action not working?

2011-02-24 Thread Richard Quadling
On 24 February 2011 15:15, Dave M G mar...@autotelic.com wrote:
 FeIn,

 Thank you for responding.


 what did you expect to happen when you call array_walk_recursive?


 What I don't understand is why it did not append to the string as it
 walked through each key/value pair.

 It seems like even though the variable inside the function called by
 array_walk_recursive has the same name as a global variable, it gets
 treated as if it only has local scope and nothing done to it applies to
 the global variable.

 --
 Dave M G

?php
function changeName($name) {
  echo My name is $name.\n;
  $name = 'Simon';
  echo My name is $name.\n;
}

$name = 'Richard';
echo My name is $name.\n;
changeName($name);
$name = 'Richard';
echo My name is $name.\n;
?

Read about variable scope at [1].


Richard.

[1] http://docs.php.net/manual/en/language.variables.scope.php

-- 
Richard Quadling
Twitter : EE : Zend
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY

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



Re: [PHP] Why is this array_walk_recursive action not working?

2011-02-24 Thread Jim Lucas
On 2/24/2011 3:01 AM, Dave M G wrote:
 PHP users,
 
 I obviously don't understand what array_walk_recursive does.
 
 Can someone break down in simple terms why the following doesn't work?
 
 - - -
 
 $karamohOutput['test'] = ;
 
 function test_print($item, $key)
 {
 return $key holds $item\n;
 }
 $karamohOutput['test'] .= array_walk_recursive($karamohArray, 'test_print');
 
 - - -
 
 Any advice would be much appreciated.
 

if you read the following page description of the function, you will see that
the function returns a bool value.  Not the return statement of your custom
function call.

http://us.php.net/array_walk_recursive

If you read the Note under the funcname section, you will see that when you call
the function, it will pass the value as a reference, so, change around your
function like this.

$karamohOutput['test'] = ;

# notice this .|
function test_print($item, $key)
{
$item = $key holds $item\n;
}
array_walk_recursive($karamohArray, 'test_print');

print_r($karamohArray);

Give this a try and let us know.

Jim Lucas

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



Re: [PHP] Why the PEAR hate?

2010-11-16 Thread Daniel Brown
On Tue, Nov 16, 2010 at 11:54, Hansen, Mike mike.han...@atmel.com wrote:

 http://www.reddit.com/r/PHP/comments/e6zs1/how_many_of_you_use_pear_in_your_projects/

 I'm still pretty new to PHP. Why the hate for PEAR? I've used a couple of 
 PEAR modules without any issues.

Some of the PEAR stuff is older and unmaintained, which is one
possible reason.  More likely is that folks often expect PEAR to be
the end-all, be-all, and that was never the intent.  PEAR is supposed
to jump-start a project and extend some built-in functionality, not
provide a framework or do all of the work for folks who consider
themselves programmers because they can iterate an array in just
twenty-seven lines of procedural code.

As for folks who say that PEAR and PECL don't work --- the most
common reason for this is user error or system configuration issues.
I've experienced the same issues myself over the years quite
frustrating, but sure enough, it was my fault most times.

-- 
/Daniel P. Brown
Network Infrastructure Manager
Documentation, Webmaster Teams
http://www.php.net/

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



Re: [PHP] Why the PEAR hate?

2010-11-16 Thread knl
On Tue, 16 Nov 2010 09:54:30 -0700
Hansen, Mike mike.han...@atmel.com wrote:

 http://www.reddit.com/r/PHP/comments/e6zs1/how_many_of_you_use_pear_in_your_projects/
 
 I'm still pretty new to PHP. Why the hate for PEAR? I've used a
 couple of PEAR modules without any issues. 

The few times I have looked at PEAR most of the modules that could
possible present a solution to my problem was very poorly documented
and in some cases the code quality was bad. I have also noticed bugs
that goes unfixed for quite some time.

I have always preferred to implement a homemade solution because of the
above.

---
Mange venlige hilsner/Best regards

Kim N. Lesmer
Programmer/Unix systemadministrator

Web: www.bitflop.com
E-mail : k...@bitflop.com
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 

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



Re: [PHP] Why is there HTML in the error_log output? Please make it stop.

2010-06-12 Thread Peter Lind
On 12 June 2010 01:17, Daevid Vincent dae...@daevid.com wrote:
 I'm trying to clean up some code and have been looking at error_log output
 and they all look like this:

 [11-Jun-2010 23:04:54] font color='red'bIn
 /var/www/my_notifications.php, line 40:  WARNING/b
 Invalid argument supplied for foreach()
 /font

 I can't figure out:

        [a] why the logs are in HTML format to begin with? Seems useless.
        [b] how do I turn it off and just be plain text (i.e. striptags()
 )?
        [c] where is this font color='red' coming from?

 I've looked in /etc/php5/apache2/ and grepped through, but don't see 'red'
 anywhere.

 I do see this, but it has no effect, as you can see by me 'disabling' it.

  388 ; String to output before an error message.
  389 ;error_prepend_string = font color=ff
  390 error_prepend_string = 
  391
  392 ; String to output after an error message.
  393 ;error_append_string = /font
  394 error_append_string = 


Did you check the html_errors directive?

Regards
Peter


-- 
hype
WWW: http://plphp.dk / http://plind.dk
LinkedIn: http://www.linkedin.com/in/plind
BeWelcome/Couchsurfing: Fake51
Twitter: http://twitter.com/kafe15
/hype

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



Re: [PHP] Why is there HTML in the error_log output? Please make it stop.

2010-06-12 Thread Peter Lind
On 12 June 2010 11:23, Peter Lind peter.e.l...@gmail.com wrote:
 On 12 June 2010 01:17, Daevid Vincent dae...@daevid.com wrote:
 I'm trying to clean up some code and have been looking at error_log output
 and they all look like this:

 [11-Jun-2010 23:04:54] font color='red'bIn
 /var/www/my_notifications.php, line 40:  WARNING/b
 Invalid argument supplied for foreach()
 /font

 I can't figure out:

        [a] why the logs are in HTML format to begin with? Seems useless.
        [b] how do I turn it off and just be plain text (i.e. striptags()
 )?
        [c] where is this font color='red' coming from?

 I've looked in /etc/php5/apache2/ and grepped through, but don't see 'red'
 anywhere.

 I do see this, but it has no effect, as you can see by me 'disabling' it.

  388 ; String to output before an error message.
  389 ;error_prepend_string = font color=ff
  390 error_prepend_string = 
  391
  392 ; String to output after an error message.
  393 ;error_append_string = /font
  394 error_append_string = 


 Did you check the html_errors directive?

Other thing that comes to mind is xdebug which will format error
output - not sure if that ends up in the error log though.

Regards
Peter


-- 
hype
WWW: http://plphp.dk / http://plind.dk
LinkedIn: http://www.linkedin.com/in/plind
BeWelcome/Couchsurfing: Fake51
Twitter: http://twitter.com/kafe15
/hype

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



Re: [PHP] Why does CURLOPT_FOLLOWLOCATION require open_basedir to be turned off?

2009-12-13 Thread Andy Shellam (Mailing Lists)
Hi,

 I was wondering why CURLOPT_FOLLOWLOCATION requires open_basedir and 
 safe_mode to be turned off.
 
 The following was found in the changelog(http://www.php.net/ChangeLog-5.php):
 
 Disabled CURLOPT_FOLLOWLOCATION in curl when open_basedir or safe_mode are 
 enabled. (Stefan E., Ilia)

I'm guessing that it would allow CURL to follow a link if a server returned a 
301 or 302 redirect.

For example, a PHP script consumes a web service or fetches a webpage from 
another server, then all of a sudden that remote server sends a 301/302 
redirect to a malicious page, CURL would then follow the redirect instead of 
returning an error.

If a server admin is paranoid enough to use safe_mode, they probably wouldn't 
want that to happen (note saying that being paranoid is a bad thing, but I've 
been managing PHP systems for years without safe_mode or open_basedir and never 
had an issue, but I can see why hosting providers may enable it.)

I can't see any conceivable benefit to this restriction when using 
open_basedir, as I thought that related to the local file system - unless CURL 
can use file:// URLs to access the local system?

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



Re: [PHP] Why does CURLOPT_FOLLOWLOCATION require open_basedir to be turned off?

2009-12-13 Thread Alex S Kurilo

I can't see any conceivable benefit to this restriction when using 
open_basedir, as I thought that related to the local file system - unless CURL 
can use file:// URLs to access the local system?

That's the problem.
I always use open_basedir (not all the sites on my servers are safe 
enough). And that so called security restriction just makes me fury 
(unless I don't see significant reasons for it). So, in order not to 
irritate my nervous system every time somebody asks me to unset 
open_basedir for CURL I decided to find the roots of that PHP 
developers' action.


And I don't think it's related to the local file system: there is 
another option that restricts protocols while redirecting, 
CURLOPT_REDIR_PROTOCOLS, which allows by default all the protocols 
supported by CURL, but file and scp. So this kind of restriction (do not 
follow file:// while redirecting) would make sense, but not disabling 
FOLLOWLOCATION at all. Either they had a better reason or they messed up 
a bit :)


Still trying to find a better explanation.

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



Re: [PHP] Why getcwd() returs different results?

2009-11-05 Thread Raymond Irving
Here's an example from the PHP website:

This demonstrates the behaviour:

?php
function echocwd() { echo 'cwd: ', getcwd(), \n; }
echocwd();
register_shutdown_function('echocwd');
?

Outputs:

cwd: /path/to/my/site/docroot/test
cwd: / 


http://php.net/manual/en/function.register-shutdown-function.php

It's a known problem but I can't see why this can't be fixed





From: Ashley Sheridan a...@ashleysheridan.co.uk
To: Raymond Irving xwis...@yahoo.com
Cc: PHP-General List php-general@lists.php.net
Sent: Thu, November 5, 2009 6:09:19 AM
Subject: Re: [PHP] Why getcwd() returs different results?

On Wed, 2009-11-04 at 17:36 -0800, Raymond Irving wrote: 
Hello,

The getcwd() method returns a different path when called from inside a 
shutdown function under Apache. On windows IIS it works just fine.

Can't this be fixed so that the path returned is consistent across servers? 

It would appear that PHP should set the CWD path before calling the shut down 
functions

__
Raymond Irving

What shutdown functions are you meaning? Do you have an example which shows the 
problem?


Thanks,
Ash
http://www.ashleysheridan.co.uk

Re: [PHP] Why aren't you rich? (was Re: unset() something that doesn't exist)

2009-08-26 Thread Richard Heyes
Hi,

 time is really what i want more of.

Personally I'd settle for a Ferrari. Or two. It would be hard, but I
think I could just about manage.

-- 
Richard Heyes
HTML5 graphing: RGraph - www.rgraph.net (updated 8th August)
Lots of PHP and Javascript code - http://www.phpguru.org
50% reseller discount on licensing now available - ideal for web designers

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



Re: [PHP] Why aren't you rich? (was Re: unset() something that doesn't exist)

2009-08-26 Thread Robert Cummings

Richard Heyes wrote:

Hi,


time is really what i want more of.


Personally I'd settle for a Ferrari. Or two. It would be hard, but I
think I could just about manage.


Might look nice in your driveway...
But without the time to drive it... :|

;)

--
http://www.interjinn.com
Application and Templating Framework for PHP

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



Re: [PHP] Why aren't you rich? (was Re: unset() something that doesn't exist)

2009-08-26 Thread Richard Heyes
Hi,

 time is really what i want more of.

 Personally I'd settle for a Ferrari. Or two. It would be hard, but I
 think I could just about manage.

 Might look nice in your driveway...
 But without the time to drive it... :|

 ;)

I actually don't have a driving license either... :-/

-- 
Richard Heyes
HTML5 graphing: RGraph - www.rgraph.net (updated 8th August)
Lots of PHP and Javascript code - http://www.phpguru.org
50% reseller discount on licensing now available - ideal for web designers

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



Re: [PHP] Why aren't you rich? (was Re: unset() something that doesn't exist)

2009-08-26 Thread Jason Pruim


On Aug 26, 2009, at 1:23 PM, Tom Worster wrote:


On 8/26/09 10:08 AM, tedd tedd.sperl...@gmail.com wrote:


I had a client say to me once If you're so smart, then why aren't
you rich?


how about: i'm smart enough that i know not to waste my allotted  
time on

this planet amassing riches.

i know plenty of rich people, many of whom earned their wealth. i  
envy the
financial security but little else of that their wealth has done to  
their
lives. time is really what i want more of. some wealthy trust fund  
types

have wealth and time but they have other problems i'm glad i don't.



I know this is a little old, but I've been busy and I wanted to chime  
in on this :)


Wealth is many things to many people... Me personally... I'm poor with  
money, but rich with spirit and other blessings... I have a loving  
wife, and two boys that think I'm the king of the world and I could do  
anything. I'd like to cover my bills a little better, and put  
something away for retirement and there college funds... but that's  
all I need :)




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



Re: [PHP] why does PHP parse *.html files in one subdir/ but not in another?

2009-07-20 Thread Stuart
2009/7/19 Paul M Foster pa...@quillandmouse.com:
 On Sun, Jul 19, 2009 at 07:18:34PM +0100, Stuart wrote:

 2009/7/19 Paul M Foster pa...@quillandmouse.com:
  On Sun, Jul 19, 2009 at 09:30:33AM +0530, kranthi wrote:
 
 
   You do realize that PHP does not parse HTML files, right? The web server
   does that. In fact, the web server also parses PHP files, using a
   different library.
 
  Kindly elaborate If you are saying that PHP cant parse files with
  extension .html
  http://us2.php.net/manual/en/security.hiding.php.
 
  That's exactly what I'm saying. Apache or IIS (or whatever) discern the
  contents of a file and determine how to parse it. As far as I know,
  Apache, even with a PHP file, parses the HTML in the file and hands PHP
  off to a PHP module to decode. The PHP engine itself does not parse the
  HTML which is interspersed in and amongst your PHP code. The web server
  does that. Unless some php internals person says otherwise, that's the
  story. At best, the PHP engine would simply echo non-PHP text to the
  browser, which is not parsing it.

 Actually that's not accurate. The web server does nothing with a file
 before it passes it to the PHP engine. PHP gets the entire file, it
 simply echo's anything not inside PHP tags.

 Then I stand corrected. But again, this means that PHP doesn't actually
 *parse* the HTML it echoes.

Technically it parses the the entire file looking for PHP tags, but
that's being overly picky.

-Stuart

-- 
http://stut.net/

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



Re: [PHP] why does PHP parse *.html files in one subdir/ but not in another?

2009-07-19 Thread Stuart
2009/7/19 Jim Lucas li...@cmsws.com:
 Govinda wrote:

 Hi all,

 ..sitting here thinking this is so easy, and I must have been over this
 already in the past..  but it is eluding me just now..

 I can't figure out why files with the .html extension ARE being parsed by
 PHP when they are in the main doc root dir/, or in one subdirectory down
 from there..  BUT NOT when in *another* new subdirectory that I just
 created.  Both subdirectories have the exact same perms (same owner  group
 too), both have the same php.ini file in them,...  neither have an .htaccess
 file in them..  (if that would matter?).

 Anyway I just need to get PHP tp process all .html files in this and in
 any new subdirectory(ies) that I will make.
 Can someone point me to what I need to pay attention to?

 Thank you
 -Govinda



 
 Govinda
 govinda.webdnat...@gmail.com



 Another thing you could do is, instead of a .htaccess, use a php.ini file in
 your
 DOCUMENT_ROOT.  Sometimes hosts allow this file.  If allowed, you will then
 be able
 to set any php.ini configuration option you want.

 Give it a shot!  What do you have to loose at this point?

Lose not loose, and php.ini has no control over what file types get
parsed by PHP.

-Stuart

-- 
http://stut.net/

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



Re: [PHP] why does PHP parse *.html files in one subdir/ but not in another?

2009-07-19 Thread Paul M Foster
On Sun, Jul 19, 2009 at 09:30:33AM +0530, kranthi wrote:

 
  You do realize that PHP does not parse HTML files, right? The web server
  does that. In fact, the web server also parses PHP files, using a
  different library.

 Kindly elaborate If you are saying that PHP cant parse files with
 extension .html
 http://us2.php.net/manual/en/security.hiding.php.

That's exactly what I'm saying. Apache or IIS (or whatever) discern the
contents of a file and determine how to parse it. As far as I know,
Apache, even with a PHP file, parses the HTML in the file and hands PHP
off to a PHP module to decode. The PHP engine itself does not parse the
HTML which is interspersed in and amongst your PHP code. The web server
does that. Unless some php internals person says otherwise, that's the
story. At best, the PHP engine would simply echo non-PHP text to the
browser, which is not parsing it.

Paul

-- 
Paul M. Foster

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



Re: [PHP] why does PHP parse *.html files in one subdir/ but not in another?

2009-07-19 Thread Ashley Sheridan
On Sun, 2009-07-19 at 14:07 -0400, Paul M Foster wrote:
 On Sun, Jul 19, 2009 at 09:30:33AM +0530, kranthi wrote:
 
  
   You do realize that PHP does not parse HTML files, right? The web server
   does that. In fact, the web server also parses PHP files, using a
   different library.
 
  Kindly elaborate If you are saying that PHP cant parse files with
  extension .html
  http://us2.php.net/manual/en/security.hiding.php.
 
 That's exactly what I'm saying. Apache or IIS (or whatever) discern the
 contents of a file and determine how to parse it. As far as I know,
 Apache, even with a PHP file, parses the HTML in the file and hands PHP
 off to a PHP module to decode. The PHP engine itself does not parse the
 HTML which is interspersed in and amongst your PHP code. The web server
 does that. Unless some php internals person says otherwise, that's the
 story. At best, the PHP engine would simply echo non-PHP text to the
 browser, which is not parsing it.
 
 Paul
 
 -- 
 Paul M. Foster
 
I thought that files that were deemed to be PHP files (indicated to the
web server by the extension and not the content) were sent to the PHP
parser, and *that* decided what bits went to the web server as regular
output.

Thanks
Ash
www.ashleysheridan.co.uk


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



Re: [PHP] why does PHP parse *.html files in one subdir/ but not in another?

2009-07-19 Thread Stuart
2009/7/19 Paul M Foster pa...@quillandmouse.com:
 On Sun, Jul 19, 2009 at 09:30:33AM +0530, kranthi wrote:


  You do realize that PHP does not parse HTML files, right? The web server
  does that. In fact, the web server also parses PHP files, using a
  different library.

 Kindly elaborate If you are saying that PHP cant parse files with
 extension .html
 http://us2.php.net/manual/en/security.hiding.php.

 That's exactly what I'm saying. Apache or IIS (or whatever) discern the
 contents of a file and determine how to parse it. As far as I know,
 Apache, even with a PHP file, parses the HTML in the file and hands PHP
 off to a PHP module to decode. The PHP engine itself does not parse the
 HTML which is interspersed in and amongst your PHP code. The web server
 does that. Unless some php internals person says otherwise, that's the
 story. At best, the PHP engine would simply echo non-PHP text to the
 browser, which is not parsing it.

Actually that's not accurate. The web server does nothing with a file
before it passes it to the PHP engine. PHP gets the entire file, it
simply echo's anything not inside PHP tags.

In general web servers don't know or care about the format of the
files they serve. You configure certain extensions to be passed to
certain modules, even in the case of something like SSI. The web
server itself doesn't usually parse any of the files it serves.

-Stuart

-- 
http://stut.net/

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



Re: [PHP] why does PHP parse *.html files in one subdir/ but not in another?

2009-07-18 Thread Govinda


On Jul 18, 2009, at 6:36 PM, Adam Shannon wrote:




On Sat, Jul 18, 2009 at 7:01 PM, Govinda  
govinda.webdnat...@gmail.com wrote:

Hi all,

..sitting here thinking this is so easy, and I must have been over  
this already in the past..  but it is eluding me just now..


I can't figure out why files with the .html extension ARE being  
parsed by PHP when they are in the main doc root dir/, or in one  
subdirectory down from there..  BUT NOT when in *another* new  
subdirectory that I just created.  Both subdirectories have the  
exact same perms (same owner  group too), both have the same  
php.ini file in them,...  neither have an .htaccess file in them..   
(if that would matter?).


Anyway I just need to get PHP tp process all .html files in this and  
in any new subdirectory(ies) that I will make.

Can someone point me to what I need to pay attention to?

It sounds like your .htaccess file may be telling .html files in a / 
sub/directory/ to treat .html files as .php


Just add this to your root .htaccess
AddType x-mapp-php5 .html


Thanks Adam.  But still no luck.  I did add that line to the .htaccess  
file in my doc root, but my file.html in subdir/ is still not being  
parsed by PHP.

??

-G

Re: [PHP] why does PHP parse *.html files in one subdir/ but not in another?

2009-07-18 Thread Adam Shannon
On Sat, Jul 18, 2009 at 7:54 PM, Govinda govinda.webdnat...@gmail.comwrote:


 On Jul 18, 2009, at 6:36 PM, Adam Shannon wrote:



 On Sat, Jul 18, 2009 at 7:01 PM, Govinda govinda.webdnat...@gmail.comwrote:

 Hi all,

 ..sitting here thinking this is so easy, and I must have been over this
 already in the past..  but it is eluding me just now..

 I can't figure out why files with the .html extension ARE being parsed by
 PHP when they are in the main doc root dir/, or in one subdirectory down
 from there..  BUT NOT when in *another* new subdirectory that I just
 created.  Both subdirectories have the exact same perms (same owner  group
 too), both have the same php.ini file in them,...  neither have an .htaccess
 file in them..  (if that would matter?).

 Anyway I just need to get PHP tp process all .html files in this and in
 any new subdirectory(ies) that I will make.
 Can someone point me to what I need to pay attention to?


 It sounds like your .htaccess file may be telling .html files in a
 /sub/directory/ to treat .html files as .php

 Just add this to your root .htaccess
 AddType x-mapp-php5 .html


 Thanks Adam.  But still no luck.  I did add that line to the .htaccess file
 in my doc root, but my file.html in subdir/ is still not being parsed by
 PHP.
 ??


Try to put that same line of .htaccess into the sub directory.  Your host
may not allow .htaccess rules to be many directories deep.



 -G




-- 
- Adam Shannon ( http://ashannon.us )


Re: [PHP] why does PHP parse *.html files in one subdir/ but not in another?

2009-07-18 Thread Adam Shannon
On Sat, Jul 18, 2009 at 7:01 PM, Govinda govinda.webdnat...@gmail.comwrote:

 Hi all,

 ..sitting here thinking this is so easy, and I must have been over this
 already in the past..  but it is eluding me just now..

 I can't figure out why files with the .html extension ARE being parsed by
 PHP when they are in the main doc root dir/, or in one subdirectory down
 from there..  BUT NOT when in *another* new subdirectory that I just
 created.  Both subdirectories have the exact same perms (same owner  group
 too), both have the same php.ini file in them,...  neither have an .htaccess
 file in them..  (if that would matter?).

 Anyway I just need to get PHP tp process all .html files in this and in any
 new subdirectory(ies) that I will make.
 Can someone point me to what I need to pay attention to?


It sounds like your .htaccess file may be telling .html files in a
/sub/directory/ to treat .html files as .php

Just add this to your root .htaccess
AddType x-mapp-php5 .html



 Thank you
 -Govinda



 
 Govinda
 govinda.webdnat...@gmail.com




-- 
- Adam Shannon ( http://ashannon.us )


Re: [PHP] why does PHP parse *.html files in one subdir/ but not in another?

2009-07-18 Thread Paul M Foster
On Sat, Jul 18, 2009 at 06:01:14PM -0600, Govinda wrote:

 Hi all,

 ..sitting here thinking this is so easy, and I must have been over
 this already in the past..  but it is eluding me just now..

 I can't figure out why files with the .html extension ARE being parsed
 by PHP when they are in the main doc root dir/, or in one subdirectory
 down from there..  BUT NOT when in *another* new subdirectory that I
 just created.  Both subdirectories have the exact same perms (same
 owner  group too), both have the same php.ini file in them,...
 neither have an .htaccess file in them..  (if that would matter?).

 Anyway I just need to get PHP tp process all .html files in this and
 in any new subdirectory(ies) that I will make.
 Can someone point me to what I need to pay attention to?

You do realize that PHP does not parse HTML files, right? The web server
does that. In fact, the web server also parses PHP files, using a
different library.

Paul

-- 
Paul M. Foster

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



Re: [PHP] why does PHP parse *.html files in one subdir/ but not in another?

2009-07-18 Thread kranthi
i never used x-mapp-php5, but most of a forums say it is specific to
1and1 hosting service. php recommends application/x-httpd-php

http://us2.php.net/manual/en/install.unix.apache2.php

try adding AddType application/x-httpd-php .html in your root htaccess
if that dosent help you'll have to add that to your htpd.conf file

 You do realize that PHP does not parse HTML files, right? The web server
 does that. In fact, the web server also parses PHP files, using a
 different library.
Kindly elaborate If you are saying that PHP cant parse files with
extension .html
http://us2.php.net/manual/en/security.hiding.php.

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



Re: [PHP] why does PHP parse *.html files in one subdir/ but not in another?

2009-07-18 Thread Govinda


Just add this to your root .htaccess
AddType x-mapp-php5 .html


Thanks Adam.  But still no luck.  I did add that line to  
the .htaccess file in my doc root, but my file.html in subdir/ is  
still not being parsed by PHP.

??

Try to put that same line of .htaccess into the sub directory.  Your  
host may not allow .htaccess rules to be many directories deep.


I just tried this, at your recommendation, but still no luck.

Re: [PHP] why does PHP parse *.html files in one subdir/ but not in another?

2009-07-18 Thread Govinda
You do realize that PHP does not parse HTML files, right? The web  
server

does that. In fact, the web server also parses PHP files, using a
different library.


I understand.  I just was saying it that way.  Actually I rarely think  
too deeply about that specifically, but now that you pointed it out I  
realize I do know that.  Thanks..

-G

Re: [PHP] why does PHP parse *.html files in one subdir/ but not in another?

2009-07-18 Thread Jim Lucas

Govinda wrote:

Hi all,

..sitting here thinking this is so easy, and I must have been over this 
already in the past..  but it is eluding me just now..


I can't figure out why files with the .html extension ARE being parsed 
by PHP when they are in the main doc root dir/, or in one subdirectory 
down from there..  BUT NOT when in *another* new subdirectory that I 
just created.  Both subdirectories have the exact same perms (same owner 
 group too), both have the same php.ini file in them,...  neither have 
an .htaccess file in them..  (if that would matter?).


Anyway I just need to get PHP tp process all .html files in this and in 
any new subdirectory(ies) that I will make.

Can someone point me to what I need to pay attention to?

Thank you
-Govinda




Govinda
govinda.webdnat...@gmail.com




Another thing you could do is, instead of a .htaccess, use a php.ini file in 
your
DOCUMENT_ROOT.  Sometimes hosts allow this file.  If allowed, you will then be 
able
to set any php.ini configuration option you want.

Give it a shot!  What do you have to loose at this point?

Jim

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



Re: [PHP] why is this SIMPLE elseif not firing?

2009-07-15 Thread Jim Lucas
Govinda wrote:
 Sorry this is isn't good 'ninja' material..  but I gotta start where I am.
 
 this:
 
 echo 'is set (EditExistingClient) ='. isset($EditExistingClient).br
 /\n;

I realize this is after the fact, but...

The above does not indicate WHAT it is set too.  Just that it is set.

it could be set to /null/, FALSE, or 0 and they would all return false,
and fail, in your if condition later on.


 is returning:
 is set (EditExistingClient) =1br /
 
 but this, later down the page:
 elseif ((isset($EditExistingClient)) || ($CreateClient)) //we just
 created a client, OR edited a client
 {
 echo 'input name=EditExistingClient type=submit value=Edit This
 Client'.\n;
 }
 
 is not firing unless $CreateClient is set.
 
 This, too, is not firing when I think it should:
 elseif (($EditExistingClient) || ($CreateClient)) //we just created a
 client, OR edited a client
 {
 echo 'input name=EditExistingClient type=submit value=Edit This
 Client'.\n;
 }
 
 what ridiculously simple thing am I missing?
 
 
 
 Govinda
 govinda.webdnat...@gmail.com
 
 



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



Re: [PHP] why is this SIMPLE elseif not firing?

2009-07-15 Thread Govinda

I realize this is after the fact, but...

The above does not indicate WHAT it is set too.  Just that it is set.

it could be set to /null/, FALSE, or 0 and they would all return  
false,

and fail, in your if condition later on.


I understand.  I appreciate your taking the time to explain things.
You too Nathan!

-G


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



Re: [PHP] why is this SIMPLE elseif not firing?

2009-07-15 Thread Stuart
2009/7/15 Govinda govinda.webdnat...@gmail.com:
 Sorry this is isn't good 'ninja' material..  but I gotta start where I am.

 this:

 echo 'is set (EditExistingClient) ='. isset($EditExistingClient).br /\n;
 is returning:
 is set (EditExistingClient) =1br /

 but this, later down the page:
 elseif ((isset($EditExistingClient)) || ($CreateClient)) //we just created a
 client, OR edited a client
 {
 echo 'input name=EditExistingClient type=submit value=Edit This
 Client'.\n;
 }

 is not firing unless $CreateClient is set.

 This, too, is not firing when I think it should:
 elseif (($EditExistingClient) || ($CreateClient)) //we just created a
 client, OR edited a client
 {
 echo 'input name=EditExistingClient type=submit value=Edit This
 Client'.\n;
 }

 what ridiculously simple thing am I missing?

The only possibility I can see is that $EditExistingClient is getting
modified between the echo and the first elseif statement.

-Stuart

-- 
http://stut.net/

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



Re: [PHP] why is this SIMPLE elseif not firing?

2009-07-15 Thread Stuart
Oops, clearly too early in the morning to be looking at code. Sorry.

-Stuart

2009/7/16 Stuart stut...@gmail.com:
 2009/7/15 Govinda govinda.webdnat...@gmail.com:
 Sorry this is isn't good 'ninja' material..  but I gotta start where I am.

 this:

 echo 'is set (EditExistingClient) ='. isset($EditExistingClient).br /\n;
 is returning:
 is set (EditExistingClient) =1br /

 but this, later down the page:
 elseif ((isset($EditExistingClient)) || ($CreateClient)) //we just created a
 client, OR edited a client
 {
 echo 'input name=EditExistingClient type=submit value=Edit This
 Client'.\n;
 }

 is not firing unless $CreateClient is set.

 This, too, is not firing when I think it should:
 elseif (($EditExistingClient) || ($CreateClient)) //we just created a
 client, OR edited a client
 {
 echo 'input name=EditExistingClient type=submit value=Edit This
 Client'.\n;
 }

 what ridiculously simple thing am I missing?

 The only possibility I can see is that $EditExistingClient is getting
 modified between the echo and the first elseif statement.

 -Stuart

 --
 http://stut.net/


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



Re: [PHP] why is this shell_exec() failing to execute my shell to create a symlink?

2009-06-27 Thread Jonathan Tapicer
Make sure that:

- The user executing the script (apache I presume) has execute
permissions on ls and ln binaries.
- The user executing the script has write persmissions on the
directory you are trying to write, and read permissions where you do
ls.
- This will probably help: put the full binary path for ls and ln, it
depends on your OS, but probably they are: /bin/ls and /bin/ln

If that doesn't help, can you show us the output?

Jonathan

On Sat, Jun 27, 2009 at 5:46 PM, Govindagovinda.webdnat...@gmail.com wrote:
 this code:

 ?php

        $testOutput = shell_exec(ls);

        $where2cd2='testDir/';
        $firstCMD=cd $where2cd2;
         $firstOutput = shell_exec($firstCMD);
        // $firstOutput = shell_exec('cd testDir/');
        $testOutput2 = shell_exec(ls);

        $secondCMD='ln -s amex_cid.gif myccGOV.gif';
        $secondOutput = shell_exec($secondCMD);

        echo testOutput:brpre$testOutput/pre;
        echo
 testOutput2:brpre$testOutput2/prebrfirstCMD=$firstCMDhr;
        echo
 firstOutput:brpre$firstOutput/prebrsecondCMD=$secondCMDhr;
        echo
 secondOutput:brpre$secondOutput/prebrthirdCMD=$thirdCMDhr;

 ?

 is not producing the symlink that I think it should.  (?!?)  (neither in the
 dir/ where this script lives, nor in the testDir/ where I am actually trying
 to create it, on the fly.
 Server is not in safe mode.


 
 Govinda
 govinda.webdnat...@gmail.com

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



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



Re: [PHP] Why does simpleXML give me nested objects for blank tags?

2009-06-22 Thread Nathan Nobbe
On Mon, Jun 22, 2009 at 2:13 PM, Daevid Vincent dae...@daevid.com wrote:

 Repost as I got zero replies. Does anyone know why this is? Seems like a
 bug
 to me, or at least should be documented as such whacky behavior. Are there
 any solutions to this or work-arounds?

 -Original Message-
 From: Daevid Vincent [mailto:dae...@daevid.com]
 Sent: Thursday, June 18, 2009 6:04 PM

 I'm trying to use
 http://us2.php.net/manual/en/function.simplexml-load-string.php

 $xml_url =
 file_get_contents('http://myserver/cgi-bin/foo.cgi?request=c901c906e4d06a0
 ')
 ;
 try
 {
  $xml = simplexml_load_string($xml_url, 'SimpleXMLElement',
LIBXML_NOBLANKS  LIBXML_COMPACT 
 LIBXML_NOEMPTYTAG);
  print_r( $xml);
 }
 catch (Exception $e)
 {
  echo bad xml;
 }

 If I have this XML file (note the tags I marked with -- below):

 issue
crstatusi_field_submitted/crstatus
problem_number151827/problem_number
problem_synopsis_fieldtitle/problem_synopsis_field
problem_description_fielddescription2/problem_description_field
fi_priorityHigh/fi_priority
 -- assignee/
create_time5/12/2009 22:53:10/create_time
 -- fi_notes_oem/
fi_sw_part_namesw_part_name/fi_sw_part_name
fi_general_referencegeneral_reference/fi_general_reference
fi_sw_part_numbersw_part_num/fi_sw_part_number
fi_customer_ecd_date1244703600/fi_customer_ecd_date
fi_sw_part_versionsw_part_version/fi_sw_part_version
fi_required_date1243839600/fi_required_date
 -- ac_type/
 /issue

 Why does it give me sub-objects and not just empty strings for tags that
 have no values as I'd expect??!


first off, why does it matter.

second, i dont think its a bug, thats just how it works,

php  $a = simplexml_load_string('blah/');
php  var_dump($a);
object(SimpleXMLElement)#1 (0) {
}


 I tried all those options above and none of them make a difference.

 SimpleXMLElement Object
 (
[crstatus] = i_field_submitted
[problem_number] = 151827
[problem_synopsis_field] = title
[problem_description_field] = description2
[fi_priority] = High
 -- [assignee] = SimpleXMLElement Object
(

)

 -- [fi_notes_oem] = SimpleXMLElement Object
(

)

[fi_sw_part_name] = sw_part_name
[fi_general_reference] = general_reference
[fi_sw_part_number] = sw_part_num
[fi_customer_ecd_date] = 1244703600
[fi_sw_part_version] = sw_part_version
[fi_required_date] = 1243839600
 -- [ac_type] = SimpleXMLElement Object
(

)

 )


third the documentation says var_dump() / print_r() are not supported, so i
wouldnt put much stock in the dump of the object above.

from the manual:
http://us2.php.net/manual/en/function.simplexml-element-attributes.php

*Note*: SimpleXML has made a rule of adding iterative properties to most
methods. They cannot be viewed using
var_dump()http://us2.php.net/manual/en/function.var-dump.phpor
anything else which can examine objects.

-nathan


Re: [PHP] Re: [Bulk] Re: [PHP] Why [?php while (true) { sleep(5); } ?] dies on CLI?

2009-06-13 Thread Ashley Sheridan
On Thu, 2009-06-11 at 20:52 +0200, Jean-Pierre Arneodo wrote:
 Ashley Sheridan a écrit :
  On Thu, 2009-06-11 at 10:47 +, Jean-Pierre Arneodo wrote:

  Hi!
  I'm stuck.
  I don't understand why the php CLI dies after 3 hours in my script.
  Any idea to solve?
  Thanks
 
 
  PHP 5.2.9-0.dotdeb.2 with Suhosin-Patch 0.9.7 (cli) (built: Apr  7 2009 
  20:06:36)
  Linux ubuntu  2.6.24-19-server #1 SMP Wed Jun 18 14:44:47 UTC 2008 x86_64 
  GNU/Linux
 
  Conf [php.ini]
  max_execution_time=0
 
  ?php
  while (true) {
  sleep(5);
  }
  ?
 
 

  
  The while loop will continue executing until its condition is false. As
  you've got a boolean true as the condition, it will never end.
 
  Thanks
  Ash
  www.ashleysheridan.co.uk

 I don't want to stop, but the process dies.
 
 I've tried the same loop with bash interpretor.
 Same result, it seems to be a ubuntu problem, not a php problem.
 
 Thanks
 
 
 
Why do you want the process to continue indefinitely? Is it for a daemon
of some kind?

Thanks
Ash
www.ashleysheridan.co.uk


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



[PHP] Re: [Bulk] Re: [PHP] Re: [Bulk] Re: [PHP] Why [?php while (true) { sleep(5); } ?] dies on CLI?

2009-06-13 Thread Jean-Pierre Arneodo

Ashley Sheridan a écrit :

On Thu, 2009-06-11 at 20:52 +0200, Jean-Pierre Arneodo wrote:
  

Ashley Sheridan a écrit :


On Thu, 2009-06-11 at 10:47 +, Jean-Pierre Arneodo wrote:
  
  

Hi!
I'm stuck.
I don't understand why the php CLI dies after 3 hours in my script.
Any idea to solve?
Thanks


PHP 5.2.9-0.dotdeb.2 with Suhosin-Patch 0.9.7 (cli) (built: Apr  7 2009 
20:06:36)
Linux ubuntu  2.6.24-19-server #1 SMP Wed Jun 18 14:44:47 UTC 2008 x86_64 
GNU/Linux

Conf [php.ini]
max_execution_time=0

?php
while (true) {
sleep(5);
}
?


  



The while loop will continue executing until its condition is false. As
you've got a boolean true as the condition, it will never end.

Thanks
Ash
www.ashleysheridan.co.uk
  
  

I don't want to stop, but the process dies.

I've tried the same loop with bash interpretor.
Same result, it seems to be a ubuntu problem, not a php problem.

Thanks





Why do you want the process to continue indefinitely? Is it for a daemon
of some kind?

Thanks
Ash
www.ashleysheridan.co.uk

  
No, it isn't a daemon, but it does something and wait the end of 
processing by polling a daemon.


# ulimit -a
core file size  (blocks, -c) 0
data seg size   (kbytes, -d) unlimited
scheduling priority (-e) 0
file size   (blocks, -f) unlimited
pending signals (-i) 38912
max locked memory   (kbytes, -l) 32
max memory size (kbytes, -m) unlimited
open files  (-n) 1024
pipe size(512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
real-time priority  (-r) 0
stack size  (kbytes, -s) 8192
cpu time   (seconds, -t) unlimited
max user processes  (-u) 38912
virtual memory  (kbytes, -v) unlimited
file locks  (-x) unlimited




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



Re: [PHP] Why [?php while (true) { sleep(5); } ?] dies on CLI?

2009-06-11 Thread Ashley Sheridan
On Thu, 2009-06-11 at 10:47 +, Jean-Pierre Arneodo wrote:
 Hi!
 I'm stuck.
 I don't understand why the php CLI dies after 3 hours in my script.
 Any idea to solve?
 Thanks
 
 
 PHP 5.2.9-0.dotdeb.2 with Suhosin-Patch 0.9.7 (cli) (built: Apr  7 2009 
 20:06:36)
 Linux ubuntu  2.6.24-19-server #1 SMP Wed Jun 18 14:44:47 UTC 2008 x86_64 
 GNU/Linux
 
 Conf [php.ini]
 max_execution_time=0
 
 ?php
 while (true) {
 sleep(5);
 }
 ?
 
 
   
The while loop will continue executing until its condition is false. As
you've got a boolean true as the condition, it will never end.

Thanks
Ash
www.ashleysheridan.co.uk


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



RE: [PHP] Why [?php while (true) { sleep(5); } ?] dies on CLI?

2009-06-11 Thread Ford, Mike
On 11 June 2009 12:00, Ashley Sheridan advised:

 On Thu, 2009-06-11 at 10:47 +, Jean-Pierre Arneodo wrote:
 Hi!
 I'm stuck.
 I don't understand why the php CLI dies after 3 hours in my script.
Any
 idea to solve? Thanks
 
 
 PHP 5.2.9-0.dotdeb.2 with Suhosin-Patch 0.9.7 (cli) (built: Apr  7
2009
 20:06:36) Linux ubuntu  2.6.24-19-server #1 SMP Wed Jun 18 14:44:47
UTC
 2008 x86_64 GNU/Linux 
 
 Conf [php.ini]
 max_execution_time=0
 
 ?php
 while (true) {
 sleep(5);
 }
 
 
 
 
 The while loop will continue executing until its condition is false.
As
 you've got a boolean true as the condition, it will never end.

I think he realises that. His question is why never equates to 3 hours
in his environment.

Cheers!

Mike

 --
Mike Ford,  Electronic Information Developer,
C507, Leeds Metropolitan University, Civic Quarter Campus, 
Woodhouse Lane, LEEDS,  LS1 3HE,  United Kingdom
Email: m.f...@leedsmet.ac.uk
Tel: +44 113 812 4730


To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm

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



Re: [PHP] Why [?php while (true) { sleep(5); } ?] dies on CLI?

2009-06-11 Thread Eddie Drapkin
try set_time_limit(0) ?

On Thu, Jun 11, 2009 at 8:05 AM, Ford, Mike m.f...@leedsmet.ac.uk wrote:

 On 11 June 2009 12:00, Ashley Sheridan advised:

  On Thu, 2009-06-11 at 10:47 +, Jean-Pierre Arneodo wrote:
  Hi!
  I'm stuck.
  I don't understand why the php CLI dies after 3 hours in my script.
 Any
  idea to solve? Thanks
 
 
  PHP 5.2.9-0.dotdeb.2 with Suhosin-Patch 0.9.7 (cli) (built: Apr  7
 2009
  20:06:36) Linux ubuntu  2.6.24-19-server #1 SMP Wed Jun 18 14:44:47
 UTC
  2008 x86_64 GNU/Linux
 
  Conf [php.ini]
  max_execution_time=0
 
  ?php
  while (true) {
  sleep(5);
  }
 
 
 
 
  The while loop will continue executing until its condition is false.
 As
  you've got a boolean true as the condition, it will never end.

 I think he realises that. His question is why never equates to 3 hours
 in his environment.

 Cheers!

 Mike

  --
 Mike Ford,  Electronic Information Developer,
 C507, Leeds Metropolitan University, Civic Quarter Campus,
 Woodhouse Lane, LEEDS,  LS1 3HE,  United Kingdom
 Email: m.f...@leedsmet.ac.uk
 Tel: +44 113 812 4730


 To view the terms under which this email is distributed, please go to
 http://disclaimer.leedsmet.ac.uk/email.htm

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




Re: [PHP] Why [?php while (true) { sleep(5); } ?] dies on CLI?

2009-06-11 Thread Robert Cummings

Ford, Mike wrote:

On 11 June 2009 12:00, Ashley Sheridan advised:


On Thu, 2009-06-11 at 10:47 +, Jean-Pierre Arneodo wrote:

Hi!
I'm stuck.
I don't understand why the php CLI dies after 3 hours in my script.

Any

idea to solve? Thanks


PHP 5.2.9-0.dotdeb.2 with Suhosin-Patch 0.9.7 (cli) (built: Apr  7

2009

20:06:36) Linux ubuntu  2.6.24-19-server #1 SMP Wed Jun 18 14:44:47

UTC
2008 x86_64 GNU/Linux 


Conf [php.ini]
max_execution_time=0

?php
while (true) {
sleep(5);
}



The while loop will continue executing until its condition is false.

As

you've got a boolean true as the condition, it will never end.


I think he realises that. His question is why never equates to 3 hours
in his environment.


Shouldn't be max execution time issue if he's running the CLI. Maybe 
account limits? Maybe the above snippet isn't what's really happening... 
I mean what purpose would the above script serve for 3 hours? Looks like 
it's been dumbed down for us dummies on the list.


Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP

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



RE: [PHP] Why [?php while (true) { sleep(5); } ?] dies on CLI?

2009-06-11 Thread kyle.smith
One of two things is happening:

- PHP is crashing, maybe a memory leak, etc.

Or

- That while(true) loop is exiting, and the script is completing.

Would be interesting to know which, try adding this after the loop:
$fp = fopen('/tmp/test','w');
fputs($fp, 'My script left the loop and exited cleanly.  True ==
false.');
fclose($fp);
 
Back on my first point, have you kept an eye on the memory usage over
the 3 hours?  If your version of PHP has a memory leak with while() or
sleep() (would be odd), a bazillion iterrations could break the PHP
defined memory limit (8M by default) and cause it to exit abruptly.

Are you capturing the output anywhere?  For example, in Linux is it
being run from cron or another script?  Try redirecting STDOUT and
STDERR somewhere useful, i.e.:

php my_php_script  /tmp/scriptoutput 21

(21 means output stream 2 [stderr] to the same place as stream 1)

Hope any of these crazy ideas are helpful...
- Kyle

 
--
Kyle Smith
Unix Systems Administrator

-Original Message-
From: Robert Cummings [mailto:rob...@interjinn.com] 
Sent: Thursday, June 11, 2009 8:25 AM
To: Ford, Mike
Cc: php-general@lists.php.net
Subject: Re: [PHP] Why [?php while (true) { sleep(5); } ?] dies on CLI?

Ford, Mike wrote:
 On 11 June 2009 12:00, Ashley Sheridan advised:
 
 On Thu, 2009-06-11 at 10:47 +, Jean-Pierre Arneodo wrote:
 Hi!
 I'm stuck.
 I don't understand why the php CLI dies after 3 hours in my script.
 Any
 idea to solve? Thanks


 PHP 5.2.9-0.dotdeb.2 with Suhosin-Patch 0.9.7 (cli) (built: Apr  7
 2009
 20:06:36) Linux ubuntu  2.6.24-19-server #1 SMP Wed Jun 18 14:44:47
 UTC
 2008 x86_64 GNU/Linux

 Conf [php.ini]
 max_execution_time=0

 ?php
 while (true) {
 sleep(5);
 }


 The while loop will continue executing until its condition is false.
 As
 you've got a boolean true as the condition, it will never end.
 
 I think he realises that. His question is why never equates to 3 
 hours in his environment.

Shouldn't be max execution time issue if he's running the CLI. Maybe
account limits? Maybe the above snippet isn't what's really happening...

I mean what purpose would the above script serve for 3 hours? Looks like
it's been dumbed down for us dummies on the list.

Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP

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


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



[PHP] Re: [Bulk] Re: [PHP] Why [?php while (true) { sleep(5); } ?] dies on CLI?

2009-06-11 Thread Jean-Pierre Arneodo

Ashley Sheridan a écrit :

On Thu, 2009-06-11 at 10:47 +, Jean-Pierre Arneodo wrote:
  

Hi!
I'm stuck.
I don't understand why the php CLI dies after 3 hours in my script.
Any idea to solve?
Thanks


PHP 5.2.9-0.dotdeb.2 with Suhosin-Patch 0.9.7 (cli) (built: Apr  7 2009 
20:06:36)
Linux ubuntu  2.6.24-19-server #1 SMP Wed Jun 18 14:44:47 UTC 2008 x86_64 
GNU/Linux

Conf [php.ini]
max_execution_time=0

?php
while (true) {
sleep(5);
}
?


  


The while loop will continue executing until its condition is false. As
you've got a boolean true as the condition, it will never end.

Thanks
Ash
www.ashleysheridan.co.uk
  

I don't want to stop, but the process dies.

I've tried the same loop with bash interpretor.
Same result, it seems to be a ubuntu problem, not a php problem.

Thanks



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



Re: [PHP] Re: [Bulk] Re: [PHP] Why [?php while (true) { sleep(5); } ?] dies on CLI?

2009-06-11 Thread Robert Cummings

Jean-Pierre Arneodo wrote:

Ashley Sheridan a écrit :

On Thu, 2009-06-11 at 10:47 +, Jean-Pierre Arneodo wrote:
 

Hi!
I'm stuck.
I don't understand why the php CLI dies after 3 hours in my script.
Any idea to solve?
Thanks


PHP 5.2.9-0.dotdeb.2 with Suhosin-Patch 0.9.7 (cli) (built: Apr  7 
2009 20:06:36)
Linux ubuntu  2.6.24-19-server #1 SMP Wed Jun 18 14:44:47 UTC 2008 
x86_64 GNU/Linux


Conf [php.ini]
max_execution_time=0

?php
while (true) {
sleep(5);
}
?


  

The while loop will continue executing until its condition is false. As
you've got a boolean true as the condition, it will never end.

Thanks
Ash
www.ashleysheridan.co.uk
  

I don't want to stop, but the process dies.

I've tried the same loop with bash interpretor.
Same result, it seems to be a ubuntu problem, not a php problem.


Open up a shell... type the following into it:

ulimit -a

What do you see?

Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP

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



Re: [PHP] Why doesn't mySQL stop a query when the browser tab is closedL

2009-06-03 Thread AngeloZanetti



Bastien Koert-3 wrote:
 
 
 
 On Jun 2, 2009, at 21:13, Daevid Vincent dae...@daevid.com wrote:
 
 I just noticed a horrible thing.

 I have a query (report) that can take 15 minutes or more to generate  
 with
 mySQL. We have  500 Million rows. This used to be done in real time  
 when we
 had less rows, but recently we got a big dump of data that shot it up.

 So, noticing via myTop the query taking so long, I closed my web  
 page tab.
 The query did NOT go away! WTF? So mysqld continued to peg the CPU  
 at 75% to
 135% (yes, top shows that if you have quad cpus. *sigh*)

 Is there some way to force this to work sanely? Some php.ini or  
 my.cnf file
 that has a setting to abort queries when the web page has gone away?

 Not sure which mailing list this belongs on so I'll post to both PHP  
 and
 mySQL. Although it feels this is a PHP problem as it should know  
 that the
 Apache thread went away and therefore close the mySQL connection and  
 kill
 the query. Conversely, mysql should know that it's connection (via  
 PHP) went
 away and should equally abort. So you're both wrong! :)
 
 Once the query is started, the only way to kill it is to kill the  
 process id in the mysql server.
 
 But I have a question about the db and current size:
 1. Do you need all that data currently? If you could archive a portion  
 away, there may be performance gains
 2. Can you partition the tables to work with smaller datasets ( could  
 be a performance gain here) ?
 
 Bastien 

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

Hi, 

have you tried to optimize the database to ensure that it runs faster? 

Also make sure you use best practices when quering the database, only search
for relevant columns and not select * from 

Hope this helps probably best to search on the mysql website for help /
research material

Let us know what your outcome is if you managed to fix it

http://www.Elemental.co.za http://www.Elemental.co.za 
http://www.wapit.co.za http://www.wapit.co.za 

-- 
View this message in context: 
http://www.nabble.com/Why-doesn%27t-mySQL-stop-a-query-when-the-browser-tab-is-closedL-tp23843810p23857439.html
Sent from the PHP - General mailing list archive at Nabble.com.


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



Re: [PHP] Why doesn't mySQL stop a query when the browser tab is closedL

2009-06-02 Thread Phpster



On Jun 2, 2009, at 21:13, Daevid Vincent dae...@daevid.com wrote:


I just noticed a horrible thing.

I have a query (report) that can take 15 minutes or more to generate  
with
mySQL. We have  500 Million rows. This used to be done in real time  
when we

had less rows, but recently we got a big dump of data that shot it up.

So, noticing via myTop the query taking so long, I closed my web  
page tab.
The query did NOT go away! WTF? So mysqld continued to peg the CPU  
at 75% to

135% (yes, top shows that if you have quad cpus. *sigh*)

Is there some way to force this to work sanely? Some php.ini or  
my.cnf file

that has a setting to abort queries when the web page has gone away?

Not sure which mailing list this belongs on so I'll post to both PHP  
and
mySQL. Although it feels this is a PHP problem as it should know  
that the
Apache thread went away and therefore close the mySQL connection and  
kill
the query. Conversely, mysql should know that it's connection (via  
PHP) went

away and should equally abort. So you're both wrong! :)


Once the query is started, the only way to kill it is to kill the  
process id in the mysql server.


But I have a question about the db and current size:
1. Do you need all that data currently? If you could archive a portion  
away, there may be performance gains
2. Can you partition the tables to work with smaller datasets ( could  
be a performance gain here) ?


Bastien 
  


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



Re: [PHP] Why does PHP have such a pain in the a$$ configuration file?

2009-05-28 Thread kranthi
phpinfo() will help you to find the differences in the configuration...

i do this every time i move to a new host(before uploading any other files
to the server, of course i delete it afterward) and change my pages
accordingly. most of the configuration settings in php.ini can be overridden
by ini_set().


Re: [PHP] Why does PHP have such a pain in the a$$ configuration file?

2009-05-27 Thread b

hessi...@hessiess.com wrote:

Something that seriously annoys me about PHP is the fact that it has
a configuration file which can *completely* change the behaviour of
the language.


Perhaps you're not at all clear on the purpose of a configuration file.

 I am seriously considering moving to a different language because of 
this.


I guess you could look for a language that has a parser with 0 
configuration options. Sounds like a bundle of fun.


Meanwhile, why don't you consider a) moving to a new host; or, b) 
setting up your own server so you can ~shudder~ *configure* it however 
you like.



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



Re: [PHP] Why does PHP have such a pain in the a$$ configuration file?

2009-05-27 Thread Michael A. Peters

b wrote:
 b) 
setting up your own server so you can ~shudder~ *configure* it however 
you like.





linode offers xen virtual machines at a very affordable rate that give 
you complete control.


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



Re: [PHP] Why does PHP have such a pain in the a$$ configuration file?

2009-05-26 Thread Robert Cummings
On Tue, 2009-05-26 at 18:30 +0100, hessi...@hessiess.com wrote:
 Something that seriously annoys me about PHP is the fact that it has
 a configuration file which can *completely* change the behaviour of
 the language. Take the following for example:
 --
 function parse_to_variable($tplname, $array = array())
 {
 $fh = fopen($tplname, 'r');
 $str = fread($fh, filesize($tplname));
 fclose($fh);
 
 extract($array);
 
 ob_start();
 eval($str);
 $result = ob_get_contents();
 ob_end_clean();
 return $result;
 }
 --
 
 Which would take a template file like this (DTD etc left out):
 --
 pList:/p
 ul
 ?php foreach($array as $item): ?
 
 liphp echo($item); ?/li
 ?php endforeach; ?
 
 /ul
 --
 
 The above code loads in the template file, eval()'s it and then saves the
 result into a variable, so that it may be intergraed into anouther element
 of a dynamic website, which is a hell of a lot cleaner than the:
 --
 echo (something . $some_variable . something_else ...);
 --
 
 mess that you find in a lot of PHP code. Not only is it hard to read, but it
 also produces awfully indented HTML, unlike the template method which outputs
 properly indented code and is much easier to read.
 
 This works perfectly so long as output buffering is enabled, however for some
 reason my web host has decided to disable output buffering in the config
 file,
 rendering the above elegant solution completely useless(*). So, why does PHP
 have to have such a pain in the a$$ configuration file. It makes developing
 platform and even install independent code a nightmare, I am seriously
 considering
 moving to a different language because of this.

Could you tell us what configuration setting they have changed? I wasn't
aware you could prevent the use of output buffering. I guess maybe if
they set output_buffering = 1 to force flushing after a single byte.
Either way, this is not a PHP issue, this is a web host problem. The
blame lies squarely on their shoulders if they have changed how
something fairly standard works. Such settings are usually made
available to people who know what they're doing and who need specific
functionality.

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


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



Re: [PHP] Why does PHP have such a pain in the a$$ configuration file?

2009-05-26 Thread Daniel Brown
On Tue, May 26, 2009 at 13:30,  hessi...@hessiess.com wrote:
 Something that seriously annoys me about PHP is the fact that it has
 a configuration file which can *completely* change the behaviour of
 the language.

We are very, very sorry that we've created an extensible language
that pleases thousands upon thousands of users, but has disappointed
you.  If you would like to file a bug report or feature request for a
complete downgrade and stripping of functionality, please visit
http://bugs.php.net/.

Thank you for your interest in PHP.

-- 
/Daniel P. Brown
daniel.br...@parasane.net || danbr...@php.net
http://www.parasane.net/ || http://www.pilotpig.net/

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



Re: [PHP] Why does PHP have such a pain in the a$$ configurationfile?

2009-05-26 Thread Shawn McKenzie
Robert Cummings wrote:
 On Tue, 2009-05-26 at 18:30 +0100, hessi...@hessiess.com wrote:
 Something that seriously annoys me about PHP is the fact that it has
 a configuration file which can *completely* change the behaviour of
 the language. Take the following for example:
 --
 function parse_to_variable($tplname, $array = array())
 {
 $fh = fopen($tplname, 'r');
 $str = fread($fh, filesize($tplname));
 fclose($fh);

 extract($array);

 ob_start();
 eval($str);
 $result = ob_get_contents();
 ob_end_clean();
 return $result;
 }
 --

 Which would take a template file like this (DTD etc left out):
 --
 pList:/p
 ul
 ?php foreach($array as $item): ?

 liphp echo($item); ?/li
 ?php endforeach; ?

 /ul
 --

 The above code loads in the template file, eval()'s it and then saves the
 result into a variable, so that it may be intergraed into anouther element
 of a dynamic website, which is a hell of a lot cleaner than the:
 --
 echo (something . $some_variable . something_else ...);
 --

 mess that you find in a lot of PHP code. Not only is it hard to read, but it
 also produces awfully indented HTML, unlike the template method which outputs
 properly indented code and is much easier to read.

 This works perfectly so long as output buffering is enabled, however for some
 reason my web host has decided to disable output buffering in the config
 file,
 rendering the above elegant solution completely useless(*). So, why does PHP
 have to have such a pain in the a$$ configuration file. It makes developing
 platform and even install independent code a nightmare, I am seriously
 considering
 moving to a different language because of this.
 
 Could you tell us what configuration setting they have changed? I wasn't
 aware you could prevent the use of output buffering. I guess maybe if
 they set output_buffering = 1 to force flushing after a single byte.
 Either way, this is not a PHP issue, this is a web host problem. The
 blame lies squarely on their shoulders if they have changed how
 something fairly standard works. Such settings are usually made
 available to people who know what they're doing and who need specific
 functionality.
 
 Cheers,
 Rob.

In addition to what Rob said, the only other option would be
implicit_flush, which is ridiculous if it is set to on.

Maybe the file that you're evaling has some ob stuff or flush() in it?

-- 
Thanks!
-Shawn
http://www.spidean.com

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



Re: [PHP] Why does PHP have such a pain in the a$$ configuration file?

2009-05-26 Thread Andrew Ballard
On Tue, May 26, 2009 at 1:47 PM, Robert Cummings rob...@interjinn.com wrote:
 [snip] Such settings are usually made
 available to people who know what they're doing and who need specific
 functionality.

 Cheers,
 Rob.

Not *quite* right. The problem is that such settings are made
available to everyone, even though they are intended for those
specific few who know what they're doing and who need specific
functionality.  :-)

Andrew

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



Re: [PHP] Why does PHP have such a pain in the a$$ configuration file?

2009-05-26 Thread Robert Cummings
On Tue, 2009-05-26 at 14:10 -0400, Andrew Ballard wrote:
 On Tue, May 26, 2009 at 1:47 PM, Robert Cummings rob...@interjinn.com wrote:
  [snip] Such settings are usually made
  available to people who know what they're doing and who need specific
  functionality.
 
  Cheers,
  Rob.
 
 Not *quite* right. The problem is that such settings are made
 available to everyone, even though they are intended for those
 specific few who know what they're doing and who need specific
 functionality.  :-)

The same is true of rat poison... ;)

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


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



Re: [PHP] Why does PHP have such a pain in the a$$ configuration file?

2009-05-26 Thread Andrew Ballard
On Tue, May 26, 2009 at 2:18 PM, Robert Cummings rob...@interjinn.com wrote:
 On Tue, 2009-05-26 at 14:10 -0400, Andrew Ballard wrote:
 On Tue, May 26, 2009 at 1:47 PM, Robert Cummings rob...@interjinn.com 
 wrote:
  [snip] Such settings are usually made
  available to people who know what they're doing and who need specific
  functionality.
 
  Cheers,
  Rob.

 Not *quite* right. The problem is that such settings are made
 available to everyone, even though they are intended for those
 specific few who know what they're doing and who need specific
 functionality.  :-)

 The same is true of rat poison... ;)

 Cheers,
 Rob.

Too true! But those who suffer ill effects from the misuse of rat
poison rarely get to complain.

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



Re: [PHP] WHY ARE lists.php.ne USER EMAIL BEING PUBLISH ON THE INTERNET

2009-05-22 Thread Per Jessen
Andrew Williams wrote:

 WHY IS php-general@lists.php.net PUBLISHING USER EMAIL ON THE
 INTERNET:
 

http://www.google.co.uk/search?q=sumitphp5%40gmail.comsourceid=navclient-ffie=UTF-8rlz=1B3GGGL_enGB303GB303aq=t
 

Isn't it common knowledge that places such as marc.info carry archives
of e.g. php-general?  I'm sure the list is also available at gmane.org.

Why are you writing in capitals - are you angry?


/Per

-- 
Per Jessen, Zürich (18.3°C)


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



RE: [PHP] WHY ARE lists.php.ne USER EMAIL BEING PUBLISH ON THE INTERNET

2009-05-22 Thread HallMarc Websites
Most likely afraid that his clients will find out he doesn't know what he is 
doing.

-Original Message-
From: Per Jessen [mailto:p...@computer.org] 
Sent: Friday, May 22, 2009 8:22 AM
To: php-general@lists.php.net
Subject: Re: [PHP] WHY ARE lists.php.ne USER EMAIL BEING PUBLISH ON THE INTERNET

Andrew Williams wrote:

 WHY IS php-general@lists.php.net PUBLISHING USER EMAIL ON THE
 INTERNET:
 

http://www.google.co.uk/search?q=sumitphp5%40gmail.comsourceid=navclient-ffie=UTF-8rlz=1B3GGGL_enGB303GB303aq=t
 

Isn't it common knowledge that places such as marc.info carry archives
of e.g. php-general?  I'm sure the list is also available at gmane.org.

Why are you writing in capitals - are you angry?


/Per

-- 
Per Jessen, Zürich (18.3°C)


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


__ Information from ESET Smart Security, version of virus signature 
database 4096 (20090522) __

The message was checked by ESET Smart Security.

http://www.eset.com




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



Re: [PHP] WHY ARE lists.php.ne USER EMAIL BEING PUBLISH ON THE INTERNET

2009-05-22 Thread Andrew Williams
I have no problem with it at least user email address should be removed off
the publication.
- Show quoted text -


On Fri, May 22, 2009 at 1:21 PM, Per Jessen p...@computer.org wrote:

 Andrew Williams wrote:

  WHY IS php-general@lists.php.net PUBLISHING USER EMAIL ON THE
  INTERNET:
 
 

 http://www.google.co.uk/search?q=sumitphp5%40gmail.comsourceid=navclient-ffie=UTF-8rlz=1B3GGGL_enGB303GB303aq=t
 

 Isn't it common knowledge that places such as marc.info carry archives
 of e.g. php-general?  I'm sure the list is also available at gmane.org.

 Why are you writing in capitals - are you angry?


 /Per

 --
 Per Jessen, Zürich (18.3°C)


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




-- 
Best Wishes
A Williams


Re: [PHP] WHY ARE lists.php.ne USER EMAIL BEING PUBLISH ON THE INTERNET

2009-05-22 Thread HallMarc Websites
Full disclosure:

 

Marc Christopher Hall

1824 Windsor Park Lane

Havertown, PA 19083

610.446.3346

 

Owner of HallMarc Websites since 2002

I was only making an observation based on a previous statement by the poster
regarding their wishes of not being found out by the client that they were
coming here for help. 

 

Thank you for asking!

 

From: help [mailto:izod...@gmail.com] 
Sent: Friday, May 22, 2009 8:50 AM
To: HallMarc Websites
Cc: php-general@lists.php.net
Subject: [SPAM] Re: [PHP] WHY ARE lists.php.ne USER EMAIL BEING PUBLISH ON
THE INTERNET

 

HallMarc,  why are you not using your name? How many client do you have on
your website?

On Fri, May 22, 2009 at 1:32 PM, HallMarc Websites
m...@hallmarcwebsites.com wrote:

Most likely afraid that his clients will find out he doesn't know what he is
doing.


-Original Message-
From: Per Jessen [mailto:p...@computer.org]
Sent: Friday, May 22, 2009 8:22 AM
To: php-general@lists.php.net
Subject: Re: [PHP] WHY ARE lists.php.ne http://lists.php.ne/  USER EMAIL
BEING PUBLISH ON THE INTERNET

Andrew Williams wrote:

 WHY IS php-general@lists.php.net PUBLISHING USER EMAIL ON THE
 INTERNET:


http://www.google.co.uk/search?q=sumitphp5%40gmail.com
http://www.google.co.uk/search?q=sumitphp5%40gmail.comsourceid=navclient-f
fie=UTF-8rlz=1B3GGGL_enGB303GB303aq=t
sourceid=navclient-ffie=UTF-8rlz=1B3GGGL_enGB303GB303aq=t


Isn't it common knowledge that places such as marc.info http://marc.info/
carry archives
of e.g. php-general?  I'm sure the list is also available at gmane.org
http://gmane.org/ .

Why are you writing in capitals - are you angry?


/Per

--
Per Jessen, Zürich (18.3°C)


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



__ Information from ESET Smart Security, version of virus signature
database 4096 (20090522) __

The message was checked by ESET Smart Security.

http://www.eset.com http://www.eset.com/ 





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




-- 
Best Wishes
A Williams





Re: [PHP] WHY ARE lists.php.ne USER EMAIL BEING PUBLISH ON THE INTERNET

2009-05-22 Thread help
HallMarc,  why are you not using your name? How many client do you have on
your website?

On Fri, May 22, 2009 at 1:32 PM, HallMarc Websites 
m...@hallmarcwebsites.com wrote:

 Most likely afraid that his clients will find out he doesn't know what he
 is doing.

 -Original Message-
 From: Per Jessen [mailto:p...@computer.org]
 Sent: Friday, May 22, 2009 8:22 AM
 To: php-general@lists.php.net
 Subject: Re: [PHP] WHY ARE lists.php.ne USER EMAIL BEING PUBLISH ON THE
 INTERNET

 Andrew Williams wrote:

  WHY IS php-general@lists.php.net PUBLISHING USER EMAIL ON THE
  INTERNET:
 
 

 http://www.google.co.uk/search?q=sumitphp5%40gmail.comsourceid=navclient-ffie=UTF-8rlz=1B3GGGL_enGB303GB303aq=t
 

 Isn't it common knowledge that places such as marc.info carry archives
 of e.g. php-general?  I'm sure the list is also available at gmane.org.

 Why are you writing in capitals - are you angry?


 /Per

 --
 Per Jessen, Zürich (18.3°C)


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


 __ Information from ESET Smart Security, version of virus signature
 database 4096 (20090522) __

 The message was checked by ESET Smart Security.

 http://www.eset.com




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




-- 
Best Wishes
A Williams


Re: [PHP] WHY ARE lists.php.ne USER EMAIL BEING PUBLISH ON THE INTERNET

2009-05-22 Thread Matty Sarro
Does it really matter? Even the best programmers communicate amongst
themselves. If your customers don't understand that, then they're going to
be sorely disappointed pretty much anywhere they go.

On Fri, May 22, 2009 at 9:06 AM, HallMarc Websites 
m...@hallmarcwebsites.com wrote:

 Full disclosure:



 Marc Christopher Hall

 1824 Windsor Park Lane

 Havertown, PA 19083

 610.446.3346



 Owner of HallMarc Websites since 2002

 I was only making an observation based on a previous statement by the
 poster
 regarding their wishes of not being found out by the client that they were
 coming here for help.



 Thank you for asking!



 From: help [mailto:izod...@gmail.com]
 Sent: Friday, May 22, 2009 8:50 AM
 To: HallMarc Websites
 Cc: php-general@lists.php.net
 Subject: [SPAM] Re: [PHP] WHY ARE lists.php.ne USER EMAIL BEING PUBLISH ON
 THE INTERNET



 HallMarc,  why are you not using your name? How many client do you have on
 your website?

 On Fri, May 22, 2009 at 1:32 PM, HallMarc Websites
 m...@hallmarcwebsites.com wrote:

 Most likely afraid that his clients will find out he doesn't know what he
 is
 doing.


 -Original Message-
 From: Per Jessen [mailto:p...@computer.org]
 Sent: Friday, May 22, 2009 8:22 AM
 To: php-general@lists.php.net
 Subject: Re: [PHP] WHY ARE lists.php.ne http://lists.php.ne/  USER EMAIL
 BEING PUBLISH ON THE INTERNET

 Andrew Williams wrote:

  WHY IS php-general@lists.php.net PUBLISHING USER EMAIL ON THE
  INTERNET:
 
 
 http://www.google.co.uk/search?q=sumitphp5%40gmail.com
 
 http://www.google.co.uk/search?q=sumitphp5%40gmail.comsourceid=navclient-f
 fie=UTF-8rlz=1B3GGGL_enGB303GB303aq=thttp://www.google.co.uk/search?q=sumitphp5%40gmail.comsourceid=navclient-f%0Afie=UTF-8rlz=1B3GGGL_enGB303GB303aq=t
 
 sourceid=navclient-ffie=UTF-8rlz=1B3GGGL_enGB303GB303aq=t
 

 Isn't it common knowledge that places such as marc.info http://marc.info/
 
 carry archives
 of e.g. php-general?  I'm sure the list is also available at gmane.org
 http://gmane.org/ .

 Why are you writing in capitals - are you angry?


 /Per

 --
 Per Jessen, Zürich (18.3°C)


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



 __ Information from ESET Smart Security, version of virus signature
 database 4096 (20090522) __

 The message was checked by ESET Smart Security.

 http://www.eset.com http://www.eset.com/





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




 --
 Best Wishes
 A Williams






Re: [PHP] Why are lists.php.net user email being publish on the internet

2009-05-22 Thread Per Jessen
Andrew Williams wrote:

 I have no problem with it at least user email address should be
 removed off the publication.
 - Show quoted text -

Don't worry, at e.g. marc.info the addresses have been appropriately
obscured.


/Per

-- 
Per Jessen, Zürich (20.4°C)


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



Re: [PHP] Why are lists.php.net user email being publish on the internet

2009-05-22 Thread Michael A. Peters

Per Jessen wrote:

Andrew Williams wrote:


I have no problem with it at least user email address should be
removed off the publication.
- Show quoted text -


Don't worry, at e.g. marc.info the addresses have been appropriately
obscured.


Bottom line is when using a public list, if you don't want your e-mail 
address to be public you use something like yahoo or gmail for the list 
mail.


Spam bots can and do subscribe to public lists to harvest e-mail 
addresses, if you are subscribed to a popular public list the spambots 
have your e-mail. That's just the way of things.


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



Re: [PHP] WHY ARE lists.php.ne USER EMAIL BEING PUBLISH ON THE INTERNET

2009-05-22 Thread Daniel Brown
On Fri, May 22, 2009 at 06:42, Andrew Williams
andrew4willi...@gmail.com wrote:
 WHY IS php-general@lists.php.net PUBLISHING USER EMAIL ON THE INTERNET:

 http://www.google.co.uk/search?q=sumitphp5%40gmail.comsourceid=navclient-ffie=UTF-8rlz=1B3GGGL_enGB303GB303aq=t


This has been the case for many, many years, and will not be
changed.  Further, it's beyond our control, as this is a public
mailing list with all communications conducted openly, with allowances
for content publishers to syndicate the content of this list as they
see fit.  As with most Internet communications, common sense tells you
that if you don't want your words to be immortalized online, unplug
your computer.  ;-P

You do have the right, however, to request (in writing to the
third-party sites) that your personal information be removed from
their systems --- including Google.

For CAPS LOCK, see also: RFC 1855 (http://tools.ietf.org/html/rfc1855)

-- 
/Daniel P. Brown
daniel.br...@parasane.net || danbr...@php.net
http://www.parasane.net/ || http://www.pilotpig.net/
50% Off All Shared Hosting Plans at PilotPig: Use Coupon DOW1

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



Re: [PHP] WHY ARE lists.php.ne USER EMAIL BEING PUBLISH ON THE INTERNET

2009-05-22 Thread Lester Caine

Andrew Williams wrote:

WHY IS php-general@lists.php.net PUBLISHING USER EMAIL ON THE INTERNET:

http://www.google.co.uk/search?q=sumitphp5%40gmail.comsourceid=navclient-ffie=UTF-8rlz=1B3GGGL_enGB303GB303aq=t


Many private lists are redistributed via archive services. Not a lot we 
can do about it as the information is quite open. When you have been 
around a few more years you will reach a decent figure on your own email 
name search ;)


--
Lester Caine - G8HFL
-
Contact - http://lsces.co.uk/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

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



Re: [PHP] Why PHP won

2009-02-24 Thread Michael A. Peters

Per Jessen wrote:

Michael A. Peters wrote:

[anip]

and you can use DOMDocument to completely
construct the page before sending it to the browser - allowing you to
translate xhtml to html for browsers that don't properly support
xhtml+xml.


I suspect you meant translate xml to html?  I publish everything in
xhtml, no browser has had a problem with that yet.




IE 6 does not accept the xml+html mime type. I don't believe IE7 does 
either, I think IE 8 beta does but I'm not sure.


If you are sending xhtml with an html mime type you are breaking a 
standard, even if it seems to work. xhtml is suppose to be sent with the 
xml+xhtml mime type.


by translating from xhtml to html 4.01 you can send the text/html mime 
type to browsers that don't report they accept applicatoiion/xml+xhtml 
and send them standards compliant html.


By using DOMDocument it is really easy to do.

Standards compliance is important, and it isn't hard to achieve.

The following is the filter I use for browsers that don't accept xml+html:

function HTMLify($buffer) {
   /* based on 
http://www.kilroyjames.co.uk/2008/09/xhtml-to-html-wordpress-plugin */

   $xhtml[] = '/script([^]*)\//';
   $html[]  = 'script\\1/script';

   $xhtml[] = '/div([^]*)\//';
   $html[]  = 'div\\1/div';

   $xhtml[] = '/a([^]*)\//';
   $html[]  = 'a\\1/a';

   $xhtml[] = '/\//';
   $html[]  = '';

   return preg_replace($xhtml, $html, $buffer);
   }

That's only part of the work, but it is the most important part.
Note that that doesn't translate all valid xhtml - it doesn't for 
example take into account legal whitespace that DOMDocument doesn't 
produce. If you want more robust translator, use an xslt filter, but 
this function is simple and doesn't require the various xslt parameters 
and libraries at php compile time.


When I create a new DOMDocument class instance -

$myxhtml = new DOMDocument(1.0,UTF-8);
$myxhtml-preserveWhiteSpace = false;
$myxhtml-formatOutput = true;
$xmlHtml = $myxhtml-createElement(html);
if ($usexml == 1) {
   $xmlHtml-setAttribute(xmlns,http://www.w3.org/1999/xhtml;);
   $xmlHtml-setAttribute(xml:lang,en);
   }

when the document is created - instead of printing the output I save it 
as a variable and then add the proper DTD:


function sendpage($page,$usexml) {
   $xhtmldtd=\n!DOCTYPE html PUBLIC \-//W3C//DTD XHTML 1.1//EN\ 
\http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\;\n;
   $htmldtd=!DOCTYPE html PUBLIC \-//W3C//DTD HTML 4.01//EN\ 
\http://www.w3.org/TR/html4/strict.dtd\;;


   if ($usexml == 0) {
  $bar=preg_replace('/\?xml version=\1.0\ 
encoding=\UTF-8\\?/',$htmldtd,$page,1);

  $bar = HTMLify($bar);
  } else {
  $bar=preg_replace('/\n/',$xhtmldtd,$page,1);
  }
   sendxhtmlheader($usexml);
   print($bar);
   }

I add the DTD there with preg_replace because I haven't yet found a 
DOMDocument way to add it, which is how it should be done - someone told 
me the DTD is currently read only in DOMDocument and that in the future, 
I'll be able to add it when a new DOMDocument class is created, so for 
now, the preg_replace hack works, and I might keep it that for some time.


To determine whether or not to send xhtml - when the page is requested 
(before any of that other code is executed) the following code is run:


if (! isset($usexml)) {
   $usexml=1;
   }
if ($usexml == 1) {
   if (isset( $_SERVER['HTTP_ACCEPT'] )) {
  if(! strpos( $_SERVER['HTTP_ACCEPT'], application/xhtml+xml ) ) {
 $usexml=0;
 }
  } else {
  $usexml=0;
  }
   }

The sendxhtmlheader function:

function sendxhtmlheader($usexml) {
   if ($usexml == 1) {
  header(Content-Type: application/xhtml+xml; charset=utf-8);
  } else {
  header(Content-type: text/html; charset=utf-8);
  }
   }

Anyway - all that is in a file I call xhtml.inc that I include in all 
my pages, then to build the document, I use the $myxhtml object that 
include creates. To send the document to the browser -


$foo=$myxhtml-saveXML();
sendpage($foo,$usexml);

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



Re: [PHP] Why PHP won

2009-02-24 Thread Per Jessen
Michael A. Peters wrote:

 Per Jessen wrote:
 Michael A. Peters wrote:
 
 [anip]
 and you can use DOMDocument to completely
 construct the page before sending it to the browser - allowing you
 to translate xhtml to html for browsers that don't properly support
 xhtml+xml.
 
 I suspect you meant translate xml to html?  I publish everything in
 xhtml, no browser has had a problem with that yet.
 
 
 IE 6 does not accept the xml+html mime type. I don't believe IE7 does
 either, I think IE 8 beta does but I'm not sure.

I don't use any of them, but I thought even IE6 was able to deal with
xml. 

 If you are sending xhtml with an html mime type you are breaking a
 standard, even if it seems to work. 
 xhtml is suppose to be sent with the xml+xhtml mime type.

From http://www.w3.org/TR/xhtml-media-types/

In general, 'application/xhtml+xml' should be used for XHTML Family
documents, and the use of 'text/html' should be limited to
HTML-compatible XHTML Family documents intended for delivery to user
agents that do not explicitly state in their HTTP Accept header that
they accept 'application/xhtml+xml' [HTTP]. 


/Per

-- 
Per Jessen, Zürich (2.7°C)


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



Re: [PHP] Why PHP won

2009-02-24 Thread Michael A. Peters

Per Jessen wrote:



I don't use any of them, but I thought even IE6 was able to deal with
xml. 


What happens is IE6 (and I believe IE7) asks the user what application 
they want to open the file with if it receives an xml+xhtml header.


IE does parse xhtml but only if sent with an incorrect html header.

IE8 is suppose to fix that, but it will probably take years before IE6/7 
is for all practical purposes out of circulation.


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



Re: [PHP] Why PHP won

2009-02-23 Thread Paul M Foster
On Mon, Feb 23, 2009 at 01:39:51PM -0800, Daevid Vincent wrote:

 http://startuplessonslearned.blogspot.com/2009/01/why-php-won.html
 

I *like* the way this guy thinks.

Paul

-- 
Paul M. Foster

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



  1   2   3   4   5   6   7   8   9   >