OSEC

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

php-general-digest-helplists.php.net
Date: Mon Jan 30 2006 - 10:01:06 CST


php-general Digest 30 Jan 2006 16:01:06 -0000 Issue 3935

Topics (messages 229439 through 229478):

Re: Retrieve output from HTML or PHP file
        229439 by: Chris
        229440 by: Peter Lauri
        229441 by: Chris
        229442 by: Michael Hulse
        229443 by: Albert

Re: Command Line PHP Advice
        229444 by: Nirmalya Lahiri
        229445 by: Nirmalya Lahiri

php and consol interface
        229446 by: Gregory Machin
        229447 by: Barry
        229451 by: Jochem Maas
        229458 by: Jochem Maas

this line throws up an undefined index.
        229448 by: Ross
        229449 by: Jochem Maas
        229450 by: Albert

writing multidimensional arrays to file ?
        229452 by: Gregory Machin
        229453 by: Barry
        229454 by: Albert
        229455 by: Barry
        229457 by: Jochem Maas
        229462 by: Gregory Machin

PHP 5 Backwards Compatability
        229456 by: Tod Thomas
        229459 by: Silvio Porcellana [tradeOver]
        229460 by: Jochem Maas

pcntl_fork?
        229461 by: Peter Hoskin
        229463 by: Jochem Maas
        229464 by: Peter Hoskin
        229465 by: Jochem Maas

Re: Collecting info about columns in a table
        229466 by: Miles Thompson

Regular expression
        229467 by: Barry
        229470 by: Silvio Porcellana [tradeOver]
        229476 by: Al

Other than default grey button
        229468 by: Jevos, Peter
        229469 by: David Grant
        229472 by: Barry
        229473 by: Jochem Maas
        229474 by: Jevos, Peter
        229475 by: John Nichel
        229477 by: Jochem Maas
        229478 by: Jevos, Peter

Re: [SOLVED] Regular expression
        229471 by: Barry

Administrivia:

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

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

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

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

attached mail follows:


Hi Peter,

Close :)

file('file.html');
see http://www.php.net/file
or

file_get_contents('file.html');
see http://www.php.net/file_get_contents

the 'file' function returns an array, 'file_get_contents' returns it as
a string.

Peter Lauri wrote:
> Best group member,
>
>
>
> I have a php script running and need to save the output from an HTML-file or
> PHP-file. What I want to do:
>
>
>
> $the_output = thenicefunction('file.html');
>
>
>
> Any suggestions?
>
>
>
> /Peter

attached mail follows:


Hi Chris,

As I read in the documentation it only takes the content of the file. If
there is a script in the file I want that to be fun first. A file like this:

----------
HTLM content
<?php echo 'Hello World'; ?>
HTML content
----------

I want the result from my function to be

----------
HTLM content
Hello World
HTML content
----------

The file_get_contents('file.html') will give me

----------
HTLM content
<?php echo 'Hello World'; ?>
HTML content
----------

Or am I not correct?

Best regards,
Peter Lauri

-----Original Message-----
From: Chris [mailto:dmagickgmail.com]
Sent: Monday, January 30, 2006 11:49 AM
To: Peter Lauri
Cc: php-generallists.php.net
Subject: Re: [PHP] Retrieve output from HTML or PHP file

Hi Peter,

Close :)

file('file.html');
see http://www.php.net/file
or

file_get_contents('file.html');
see http://www.php.net/file_get_contents

the 'file' function returns an array, 'file_get_contents' returns it as
a string.

Peter Lauri wrote:
> Best group member,
>
>
>
> I have a php script running and need to save the output from an HTML-file
or
> PHP-file. What I want to do:
>
>
>
> $the_output = thenicefunction('file.html');
>
>
>
> Any suggestions?
>
>
>
> /Peter

attached mail follows:


Hi Peter,

Ah, I understand now.

If the file echo'ed it's output you could do:

ob_start();
include('file.php');
$output = ob_get_contents();
ob_end_clean();

or:

$output = exec('script.php');

(but make sure you use escapeshellarg &/or escapeshellcmd where
applicable for security reasons).

first method would be better, more robust and more portable.

Peter Lauri wrote:
> Hi Chris,
>
> As I read in the documentation it only takes the content of the file. If
> there is a script in the file I want that to be fun first. A file like this:
>
> ----------
> HTLM content
> <?php echo 'Hello World'; ?>
> HTML content
> ----------
>
> I want the result from my function to be
>
> ----------
> HTLM content
> Hello World
> HTML content
> ----------
>
> The file_get_contents('file.html') will give me
>
> ----------
> HTLM content
> <?php echo 'Hello World'; ?>
> HTML content
> ----------
>
> Or am I not correct?
>
> Best regards,
> Peter Lauri
>
>
>
>
> -----Original Message-----
> From: Chris [mailto:dmagickgmail.com]
> Sent: Monday, January 30, 2006 11:49 AM
> To: Peter Lauri
> Cc: php-generallists.php.net
> Subject: Re: [PHP] Retrieve output from HTML or PHP file
>
> Hi Peter,
>
> Close :)
>
> file('file.html');
> see http://www.php.net/file
> or
>
> file_get_contents('file.html');
> see http://www.php.net/file_get_contents
>
> the 'file' function returns an array, 'file_get_contents' returns it as
> a string.
>
> Peter Lauri wrote:
>
>>Best group member,
>>
>>
>>
>>I have a php script running and need to save the output from an HTML-file
>
> or
>
>>PHP-file. What I want to do:
>>
>>
>>
>>$the_output = thenicefunction('file.html');
>>
>>
>>
>>Any suggestions?
>>
>>
>>
>>/Peter
>
>

attached mail follows:


I have used output buffering[1] in the past to do what you are
describing.

<snip>

# HTML to be written:
ob_start(); // Begin output buffering:
        require($_SERVER['DOCUMENT_ROOT'].$path.'/
'.$name_of_template.$name_of_template_ext);
        $message = ob_get_contents(); // Put contents of the above require
into $message.
ob_end_clean(); // Clean the output buffer.

</snip>

Probably better ways to do above, but maybe that will help you in some
way.

Oh, you may also want to look into the eval() function[2].

[1] http://us2.php.net/manual/en/function.ob-start.php
[2] http://us2.php.net/manual/en/function.eval.php

Cheers, Micky
--
BCC for Privacy: http://www.cs.rutgers.edu/~watrous/bcc-for-privacy.html
My del.icio.us: http://del.icio.us/mhulse

attached mail follows:


Peter Lauri wrote:
> As I read in the documentation it only takes the content of the file. If
> there is a script in the file I want that to be fun first. A file like
> this:
>
> ----------
> HTLM content
> <?php echo 'Hello World'; ?>
> HTML content
> ----------
>
> I want the result from my function to be
>
> ----------
> HTLM content
> Hello World
> HTML content
> ----------
>
> The file_get_contents('file.html') will give me
>
> ----------
> HTLM content
> <?php echo 'Hello World'; ?>
> HTML content
> ----------
>
> Or am I not correct?

Yes you are correct.

Why don't you include the file? PHP will parse the PHP inside it and output
the HTML...

If you want to get the contents into a variable then do something like:
<?
ob_start();
include("file.html");
$fileContent = ob_get_contents();
ob_clean();
?>

Albert

--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.375 / Virus Database: 267.14.23/243 - Release Date: 2006/01/27
 

attached mail follows:


 
Hi,
 you can do this by using unix command 'for'. Please apply the
command written below & reply me your experiment result.

for filename in `ls *.txt`;do ./edit.php $filename var1 var2;done

--Nirmalya
 

Angelo Christou <christou44yahoo.com> wrote: Hello List
I would like some advice from PHP users regarding PHP and the command line. I have a PHP script that does a whole bunch of stuff to a file on my intranet.

./edit.php filename var1 var2

Everything works fine but I need to run it on a list of files -

./edit.php invoice00212.txt var1 var2
./edit.php invoice00213.txt var1 var2
./edit.php invoice00214.txt var1 var2

I have a list of several thousand files that will change every month. The list has the filenames and variables, like this so I am half way there I think -

invoice00212.txt var1 var2
invoice00213.txt var1 var2
invoice00214.txt var1 var2

My question is how should I incorporate this with my PHP script?

I read that it's better to split scripts up into small reusable parts so my plan is to keep the logic out of the edit.php script and simply pass the variables to it using another script. Am I on the right path doing this?

I am only a beginner with PHP so I admit I don’t really know what I’m doing, that is why I am asking for pointers from the PHP Mail List :)

Below is my model, however I am unsure how to achieve this or even if it's the best way to do it?

open filelist.txt
for each line create $filename $var1 $var2
then run
./edit.php $filename $var1 $var2
loop back to the next line
end

Many thanks in advance,
Ang.
 

  
---------------------------------
Do you Yahoo!?
 With a free 1 GB, there's more in store with Yahoo! Mail.

                                
---------------------------------
Bring words and photos together (easily) with
 PhotoMail - it's free and works with your Yahoo! Mail.

attached mail follows:


Angelo,
  I am very happy after knowing that it is working. :)
 
 --Nirmalya
 
 
Angelo Christou <christou44yahoo.com> wrote:
Hello Nirmalya,

Thank you for your response. With the help of your reply, I've now got it working! :)

Ang.

Nirmalya Lahiri <nirmalyalahiriyahoo.com> wrote: Hi,
 you can do this by using unix command 'for'. Please apply the
command written below......& reply me your experiment result.

for filename in `ls *.txt`;do ./edit.php $filename var1 var2;done

--Nirmalya

--- Angelo Christou wrote:

> Hello List
> I would like some advice from PHP users regarding PHP and the
> command line. I have a PHP script that does a whole bunch of stuff
> to a file on my intranet.
>
> ./edit.php filename var1 var2
>
> Everything works fine but I need to run it on a list of files -
>
> ./edit.php invoice00212.txt var1 var2
> ./edit.php invoice00213.txt var1 var2
> ./edit.php invoice00214.txt var1 var2
>

       

---------------------------------
Bring words and photos together (easily) with
  PhotoMail - it's free and works with your Yahoo! Mail.

                                
---------------------------------
Bring words and photos together (easily) with
 PhotoMail - it's free and works with your Yahoo! Mail.

attached mail follows:


Hi
I'm developing a web interface for server admin in php, but the bos has
added a complication, he wants ssh / telnet colson for as well, is i
posible to create a consol app in php ? My original idea was to have a
couple of files that the web interface would you to stor the settings and
generate the configs, but now i have to rethink my planning because of the
consol interface. Would you have any sugestions on how to keep consistancy
between the 2 interfaces configurations ie. if the config is changed at the
consol it should be reflected on the web interfact..

Thanks for you time

--
Gregory Machin
greglinuxpro.co.za
gregory.machingmail.com
www.linuxpro.co.za
www.exponent.co.za
Web Hosting Solutions
Scalable Linux Solutions
www.iberry.info (support and admin)

+27 72 524 8096

attached mail follows:


Gregory Machin wrote:
> Hi
> I'm developing a web interface for server admin in php, but the bos has
> added a complication, he wants ssh / telnet colson for as well, is i
> posible to create a consol app in php ? My original idea was to have a
> couple of files that the web interface would you to stor the settings and
> generate the configs, but now i have to rethink my planning because of the
> consol interface. Would you have any sugestions on how to keep consistancy
> between the 2 interfaces configurations ie. if the config is changed at the
> consol it should be reflected on the web interfact..
>
> Thanks for you time

Hi Gregory,

this is quite a problem because you actually don't have real time output
and input on your browser.
You could execute simple shell commands with the exec function
http://de2.php.net/exec

But any more complicated will be a hard run.

You would have to get the output and let somone add in the next command.
Then the page reloads with the output you got already and so on.

This might probably work, but PHP is surely not designed for things like
that.

I would say that it would be much easier to code something in JAVA then
trying to accomplish that in PHP.

Barry

--
Smileys rule (cX.x)C --o(^_^o)

attached mail follows:


Gregory Machin wrote:
> Hi
> I'm developing a web interface for server admin in php, but the bos has
> added a complication, he wants ssh / telnet colson for as well, is i

your boss has just (theoretically) doubled the ammount of work you have to do,
a cmdline interface is not something you bolt on as an after thought! it's
just as much an interface (with all the potential hard work it takes to get
it working properly) as an application webpage.

> posible to create a consol app in php ? My original idea was to have a
> couple of files that the web interface would you to stor the settings and
> generate the configs, but now i have to rethink my planning because of the
> consol interface. Would you have any sugestions on how to keep consistancy
> between the 2 interfaces configurations ie. if the config is changed at the

use a single config file (use a ini type file?) or maybe a DB. just make
sure you have some kind of update locking (check out the flock() function for
example) so that changes don't overwrite each other or bork the config file
somehow.

> consol it should be reflected on the web interfact..

I don't think the real-time (on the cmdline) versus browser-time intertaction
is an issue. especially if you consider that you could write the cmdline interface
in the same way as the PEAR command works. the pear command is an executable php
script that excepts many, many commands (relevant to PEAR isntall/repository management)
which is called from your shell, e.g.:

?> pear install apc

a normally SSH connection to the box gives access - rather than a direct connection to
a port that hosts the cmdline application (or course its quite possible to write a php
cmdline app. that runs as a telnet-like deamon, but personally I'd keep it simple
and write a php shell script for which you need to SSH into the relevant box to
use the script/tool.

>
> Thanks for you time
>
>
>
> --
> Gregory Machin
> greglinuxpro.co.za
> gregory.machingmail.com
> www.linuxpro.co.za
> www.exponent.co.za
> Web Hosting Solutions
> Scalable Linux Solutions
> www.iberry.info (support and admin)
>
> +27 72 524 8096

attached mail follows:


Gregory Machin wrote:
> Thanks for the input ..
> yes my idea was to use an ".ini" to store the configs. Do you know of
> any tutorials for creating php command line interafaces / applications ..
> The biggest problem is that the 2 interfaces have to share the same
> config, other wise there could be hug problems ..

so write an underlying module that takes care of reading and writing
ini settings.

try this:
http://www.devshed.com/index2.php?option=content&task=view&id=333&pop=1&hide_ads=1&page=0&hide_js=1

which is a tut. on using this:
http://pear.php.net/manual/en/package.configuration.config.php

>
> On 1/30/06, *Jochem Maas* <jochemiamjochem.com
> <mailto:jochemiamjochem.com>> wrote:
>
> Gregory Machin wrote:
> > Hi
> > I'm developing a web interface for server admin in php, but the
> bos has
> > added a complication, he wants ssh / telnet colson for as well, is i
>
> your boss has just (theoretically) doubled the ammount of work you
> have to do,
> a cmdline interface is not something you bolt on as an after
> thought! it's
> just as much an interface (with all the potential hard work it takes
> to get
> it working properly) as an application webpage.
>
> > posible to create a consol app in php ? My original idea was
> to have a
> > couple of files that the web interface would you to stor the
> settings and
> > generate the configs, but now i have to rethink my planning
> because of the
> > consol interface. Would you have any sugestions on how to keep
> consistancy
> > between the 2 interfaces configurations ie. if the config is
> changed at the
>
> use a single config file (use a ini type file?) or maybe a DB. just make
> sure you have some kind of update locking (check out the flock()
> function for
> example) so that changes don't overwrite each other or bork the
> config file
> somehow.
>
> > consol it should be reflected on the web interfact..
>
> I don't think the real-time (on the cmdline) versus browser-time
> intertaction
> is an issue. especially if you consider that you could write the
> cmdline interface
> in the same way as the PEAR command works. the pear command is an
> executable php
> script that excepts many, many commands (relevant to PEAR
> isntall/repository management)
> which is called from your shell, e.g.:
>
> ?> pear install apc
>
> a normally SSH connection to the box gives access - rather than a
> direct connection to
> a port that hosts the cmdline application (or course its quite
> possible to write a php
> cmdline app. that runs as a telnet-like deamon, but personally I'd
> keep it simple
> and write a php shell script for which you need to SSH into the
> relevant box to
> use the script/tool.
>
> >
> > Thanks for you time
> >
> >
> >
> > --
> > Gregory Machin
> > greglinuxpro.co.za <mailto:greglinuxpro.co.za>
> > gregory.machingmail.com <mailto:gregory.machingmail.com>
> > www.linuxpro.co.za <http://www.linuxpro.co.za>
> > www.exponent.co.za <http://www.exponent.co.za>
> > Web Hosting Solutions
> > Scalable Linux Solutions
> > www.iberry.info <http://www.iberry.info> (support and admin)
> >
> > +27 72 524 8096
>
>
>

attached mail follows:


<? $filename = basename($_SERVER['SCRIPT_FILENAME']);
$link= "../text_only/$filename";
?>

any ideas how to prevent this error?

attached mail follows:


Ross wrote:
> <? $filename = basename($_SERVER['SCRIPT_FILENAME']);
> $link= "../text_only/$filename";
> ?>
>
>
> any ideas how to prevent this error?

$_SERVER is an array. and also a variable. we can be sure
it exists if we are running a webserver php module, so we don't need
to test if it's set or not BUT the index of the array pointed to
by 'SCRIPT_FILENAME' does not necessarily exist so
(the contents of the $_SERVER is different from server to server)...

$filename = basename($_SERVER['SCRIPT_FILENAME']);
if (!$filename) {
        die('yuck!');
}

or something like:

if (!isset($_SERVER['SCRIPT_FILENAME'])) {
        die('yuck!');
} else {
        $filename = basename($_SERVER['SCRIPT_FILENAME']);
}

to see what's in $_SERVER do something like:

ecoh '<pre>'; // this line assumes you are viewing the output via a webbrowser!
print_r($_SERVER);
>

attached mail follows:


Ross wrote:
> <? $filename = basename($_SERVER['SCRIPT_FILENAME']);
> $link= "../text_only/$filename";
> ?>
>
>
> any ideas how to prevent this error?

From the PHP Documentation:
"$_SERVER is an array containing information such as headers, paths, and
script locations. The entries in this array are created by the webserver.
There is no guarantee that every webserver will provide any of these;
servers may omit some, or provide others not listed here. That said, a large
number of these variables are accounted for in the » CGI 1.1 specification,
so you should be able to expect those. "

If you are executing a script on the command line it will not exist.

Try using argc and argv for that. The filename is typically argv[0].

isset($_SERVER['SCRIPT_FILENAME']) will return true if the index exist.

Albert

--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.375 / Virus Database: 267.14.23/243 - Release Date: 2006/01/27
 

attached mail follows:


Hi
I'm looking for a good example of writing multidimensional arrays, and
reading them back .

Thanks for you time .

--
Gregory Machin
greglinuxpro.co.za
gregory.machingmail.com
www.linuxpro.co.za
www.exponent.co.za
Web Hosting Solutions
Scalable Linux Solutions
www.iberry.info (support and admin)

+27 72 524 8096

attached mail follows:


Gregory Machin wrote:
> Hi
> I'm looking for a good example of writing multidimensional arrays, and
> reading them back .
>
> Thanks for you time .
>

serialize:
http://de.php.net/serialize

Greets
        Barry

--
Smileys rule (cX.x)C --o(^_^o)

attached mail follows:


Gregory Machin [mailto:gregory.machingmail.com]
> Hi
> I'm looking for a good example of writing multidimensional arrays, and
> reading them back .

http://za2.php.net/manual/en/function.serialize.php
and
http://za2.php.net/manual/en/function.unserialize.php

Call serialize() when saving the array to the file and unserialize() to read
it back

--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.375 / Virus Database: 267.14.23/243 - Release Date: 2006/01/27
 

attached mail follows:


Gregory Machin wrote:
> Hi
> I'm looking for a good example of writing multidimensional arrays, and
> reading them back .
>
> Thanks for you time .
>
serialize:
http://de3.php.net/serialize

http://de3.php.net/manual/en/function.unserialize.php

Greets
        Barry

--
Smileys rule (cX.x)C --o(^_^o)

attached mail follows:


Gregory Machin wrote:
> Hi
> I'm looking for a good example of writing multidimensional arrays, and
> reading them back .

serialize() and alternatively if you find it handy to be able to
manually read the contents of the array written to the file there is also
var_export() which can return valid php code in a readable form.

>
> Thanks for you time .
>
> --
> Gregory Machin
> greglinuxpro.co.za
> gregory.machingmail.com
> www.linuxpro.co.za
> www.exponent.co.za
> Web Hosting Solutions
> Scalable Linux Solutions
> www.iberry.info (support and admin)
>
> +27 72 524 8096

attached mail follows:


Thanks for you input. I will lookinto alt the sugetions. Many thanks/. Have
a grate day .

On 1/30/06, Jochem Maas <jochemiamjochem.com> wrote:
>
> Gregory Machin wrote:
> > Hi
> > I'm looking for a good example of writing multidimensional arrays, and
> > reading them back .
>
> serialize() and alternatively if you find it handy to be able to
> manually read the contents of the array written to the file there is also
> var_export() which can return valid php code in a readable form.
>
> >
> > Thanks for you time .
> >
> > --
> > Gregory Machin
> > greglinuxpro.co.za
> > gregory.machingmail.com
> > www.linuxpro.co.za
> > www.exponent.co.za
> > Web Hosting Solutions
> > Scalable Linux Solutions
> > www.iberry.info (support and admin)
> >
> > +27 72 524 8096
>
>

--
Gregory Machin
greglinuxpro.co.za
gregory.machingmail.com
www.linuxpro.co.za
www.exponent.co.za
Web Hosting Solutions
Scalable Linux Solutions
www.iberry.info (support and admin)

+27 72 524 8096

attached mail follows:


Is their a list of portability problems to be aware of when switching
from v4 to v5? Maybe a table that compares the two?

Thanks.

attached mail follows:


Tod Thomas wrote:
> Is their a list of portability problems to be aware of when switching
> from v4 to v5? Maybe a table that compares the two?
>
> Thanks.
>

You can start here:
http://www.zend.com/php5/migration.php

Silvio

--
tradeOver | http://www.tradeover.net
...ready to become the King of the World?

attached mail follows:


Tod Thomas wrote:
> Is their a list of portability problems to be aware of when switching
> from v4 to v5? Maybe a table that compares the two?

other than the stuff on php.net (no comparison tables exactly)
not really - plenty of people on this list that will help you if you
run into problems.

sidenote: the reference related fixes introduced into php4.4 (and php5+)
can be a PITA, avoid using references unless you..

a, really know what you are doing.
b, you really need a reference.

...objects in php5 don't need to be passed around by reference - in fact
I suggest the first thing you do when updating your code is to remove
reference syntax related to passing around objects :-)

>
> Thanks.
>

attached mail follows:


Hi,

I have written a script to parse a large amount of XML data and insert
it into SQL... deals with approx 80,000 rows each time I run it. I
cannot successfully complete this script without running out of memory.
Is pcntl_fork suitable to overcome this?

I have been playing with pcntl_fork and became completely stuck trying
to select data from a database and spawn a new fork for each row. Later
I'll have to use something like shmop so each child knows what row its
working on, and will do a series of xml parsing based on supplied data..
a simple example of forking with a foreach this way would be appreciated

Regards,
Peter Hoskin

attached mail follows:


Peter Hoskin wrote:
> Hi,
>
> I have written a script to parse a large amount of XML data and insert
> it into SQL... deals with approx 80,000 rows each time I run it. I
> cannot successfully complete this script without running out of memory.

how much memory do you have set as the max?
do you have control over this value? (i.e. is it not locked down by an admin)
what are you doing with each row? (I imagine that effectively you
only need on row in memory at a time - in which case the memory requirements are
probably quite conservative)

show us your code if you can :-)

> Is pcntl_fork suitable to overcome this?

it may offer one suitable solution. but I would suggest looking at your
code again before adding another level of complexity that may not bee needed
(I would suggest that forking would be a good idea to improve the performance
by allowing parallel processing but not to fix a crash perse)

>
> I have been playing with pcntl_fork and became completely stuck trying
> to select data from a database and spawn a new fork for each row. Later
> I'll have to use something like shmop so each child knows what row its
> working on, and will do a series of xml parsing based on supplied data.

I doubt you need shmop given that each child gets a complete copy of the
parent processes address space (i.e. all variables, etc that were defined in the
parent process will also be available in each child process)

there are some examples in the user comments on this page:
http://php.net/manual/en/function.pcntl-fork.php

> a simple example of forking with a foreach this way would be appreciated
>
> Regards,
> Peter Hoskin
>

attached mail follows:


Jochem Maas wrote:
> how much memory do you have set as the max?
512mb
> do you have control over this value? (i.e. is it not locked down by an
> admin)
yes
> what are you doing with each row? (I imagine that effectively you
 From each row, I determine what XML files to fetch and parse... the
parser then inserts them into SQL.

This is really the second part of the parsing, the first pass fetches
the concerned table as XML and parses it.

Each XML file I fetch can be between 15-50 rows.
> only need on row in memory at a time - in which case the memory
> requirements are
> probably quite conservative)
>
> show us your code if you can :-)
It came down to my code I think... wasn't using it appropriately. I read
the post 'pcntl functions and database' from this list a few days ago,
and it had a good example... so far I've come up with:

<?
require_once('../private/sql.php');

$pgconnectstring='dbname=' . returndbname() . ' user=' . returndbuser()
. ' password=' . returndbpass() . ' host=redback.10mbit.biz';
$database = pg_connect($pgconnectstring);

$query = "SELECT count(key) AS count FROM tvguide_channels WHERE
crawl=true;";
$result = pg_query($database,$query);
$row = pg_fetch_object($result,0);

$childcount = 0;
$childrencount = $row->count;
while($childcount < $childrencount) {
    $pid = pcntl_fork();

    if ( $pid == -1 ) {
        die("Unable to fork\n");
    } elseif ($pid == 0) {
        $childcount++;
        pcntl_wait($status);
        continue;
    } else {
        echo $childcount ." ". posix_getpid() ." ". posix_getppid() ."\n";
        exit();
    }
}
?>

Each fork seems to be able to see the value of $childcount... so I just
need to create a function to work with a particular row. Having a
counter is precisely what I needed as I can then use
pg_fetch_object($result,$childcount)

Regards,
Peter Hoskin

attached mail follows:


Peter Hoskin wrote:
>
>
> Jochem Maas wrote:
>
>> how much memory do you have set as the max?
>
> 512mb

should be enough. :-)

just to give it perspective I have a text file I
import on at least a weekly basis (someone else does it actually but
i wrote the code) that contains 500,000+ lines representing
customers each of which is imported/updated into firebird DB
(mostly not as fast as mysql) using a transaction. the code works and only
chews up about 100Mbs (which is mostly due to the garbage collector not
being able to release memory belonging to objects that have circular
references)

>
>> do you have control over this value? (i.e. is it not locked down by an
>> admin)
>
> yes
>
>> what are you doing with each row? (I imagine that effectively you
>
> From each row, I determine what XML files to fetch and parse... the
> parser then inserts them into SQL.
>
> This is really the second part of the parsing, the first pass fetches
> the concerned table as XML and parses it.
>
> Each XML file I fetch can be between 15-50 rows.

I get the feeling you should be unsetting variables more actively inside
your loops. also avoid objects (specifically/especially ones with circular
'references'** - i.e. parent<-->child type 'references'**)

** - I use 'references' to mean in the general english language
sense not in the php sense. although if you're using php4 then most probably
your object variables should actually be php-references!

>
>> only need on row in memory at a time - in which case the memory
>> requirements are
>> probably quite conservative)
>>
>> show us your code if you can :-)
>
> It came down to my code I think... wasn't using it appropriately. I read
> the post 'pcntl functions and database' from this list a few days ago,
> and it had a good example... so far I've come up with:
>
> <?
> require_once('../private/sql.php');
>
> $pgconnectstring='dbname=' . returndbname() . ' user=' . returndbuser()
> . ' password=' . returndbpass() . ' host=redback.10mbit.biz';
> $database = pg_connect($pgconnectstring);
>
> $query = "SELECT count(key) AS count FROM tvguide_channels WHERE
> crawl=true;";
> $result = pg_query($database,$query);
> $row = pg_fetch_object($result,0);
>
> $childcount = 0;
> $childrencount = $row->count;
> while($childcount < $childrencount) {
> $pid = pcntl_fork();
>
> if ( $pid == -1 ) {
> die("Unable to fork\n");
> } elseif ($pid == 0) {
> $childcount++;
> pcntl_wait($status);
> continue;
> } else {
> echo $childcount ." ". posix_getpid() ." ". posix_getppid() ."\n";
> exit();
> }
> }
> ?>
>
> Each fork seems to be able to see the value of $childcount... so I just
> need to create a function to work with a particular row. Having a
> counter is precisely what I needed as I can then use
> pg_fetch_object($result,$childcount)

moving forward, always nice to make progress :-)

>
> Regards,
> Peter Hoskin
>

attached mail follows:


No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.1.375 / Virus Database: 267.14.23/243 - Release Date: 1/27/2006

attached mail follows:


Simple reg help please

i want to match the last "," in "a,b,c,d" and replace it with " and "

i tried ereg_replace(",([a-zA-z])*$"," and ",$string);

but i forgot how to add the "d" which is also matched now back to the
" and "

Can you give any good reg_exp sites where to learn it?
Its long ago since i used reg exp and i lost the hang of it... :(

btw. any sites that have reg_exp that works witht PHP would be fine.
i know http://www.regular-expressions.info/tutorial.html
But that examples dont work with preg_match and ereg.

Thanks ^_^

--
Smileys rule (cX.x)C --o(^_^o)

attached mail follows:


Barry wrote:
> Simple reg help please
>
> i want to match the last "," in "a,b,c,d" and replace it with " and "
>

Without using a regexp, you could do:

<code>
   $string = 'a,b,c,d';
   $letters = explode(',', $string);
   $last_letter = array_pop($letters);
   $final_string = implode(',', $letters) . ' and ' . $last_letter;
</code>

Not very efficient - but should work...

Silvio

--
tradeOver | http://www.tradeover.net
...ready to become the King of the World?

attached mail follows:


Barry wrote:
> Simple reg help please
>
> i want to match the last "," in "a,b,c,d" and replace it with " and "
>
> i tried ereg_replace(",([a-zA-z])*$"," and ",$string);
>
> but i forgot how to add the "d" which is also matched now back to the
> " and "
>
> Can you give any good reg_exp sites where to learn it?
> Its long ago since i used reg exp and i lost the hang of it... :(
>
> btw. any sites that have reg_exp that works witht PHP would be fine.
> i know http://www.regular-expressions.info/tutorial.html
> But that examples dont work with preg_match and ereg.
>
> Thanks ^_^
>
Try this:

$pattern= "%,([\w\.]+)$%"; //put any line ending punctuation in the []
$replace= " and $1"; //may need $replace= " and " . $1;

$string= preg_replace($pattern, $replace, $string);

attached mail follows:


Hi all

I'd like to ask you one ( probably ) simple question. I'm using webmail
and I want to use other than default php grey button.
I found on the pages how to use image instead of the default button. So
I changed

INPUT TYPE="submit" NAME="move_button" VALUE="Move"

to

INPUT TYPE="image'" NAME="move_button" VALUE="Move"
SRC="../images/button.jpg" width="19" height="50"

It works but I found the other important problem. This is image. What
happend when I change the language ? Nothing cause this is permanent
image and text "Move" is replaced by image

So what should I do to change design of the button without using image ?

Thanks a lot for an answers

attached mail follows:


Peter,

You need to investigate CSS.

David

Jevos, Peter wrote:
> Hi all
>
> I'd like to ask you one ( probably ) simple question. I'm using webmail
> and I want to use other than default php grey button.
> I found on the pages how to use image instead of the default button. So
> I changed
>
> INPUT TYPE="submit" NAME="move_button" VALUE="Move"
>
> to
>
> INPUT TYPE="image'" NAME="move_button" VALUE="Move"
> SRC="../images/button.jpg" width="19" height="50"
>
> It works but I found the other important problem. This is image. What
> happend when I change the language ? Nothing cause this is permanent
> image and text "Move" is replaced by image
>
> So what should I do to change design of the button without using image ?
>
> Thanks a lot for an answers
>

--
David Grant
http://www.grant.org.uk/

http://pear.php.net/package/File_Ogg 0.2.1
http://pear.php.net/package/File_XSPF 0.1.0

WANTED: Junior PHP Developer in Bristol, UK

attached mail follows:


Jevos, Peter wrote:
> Hi all
>
> I'd like to ask you one ( probably ) simple question. I'm using webmail
> and I want to use other than default php grey button.
> I found on the pages how to use image instead of the default button. So
> I changed
>
> INPUT TYPE="submit" NAME="move_button" VALUE="Move"
>
> to
>
> INPUT TYPE="image'" NAME="move_button" VALUE="Move"
> SRC="../images/button.jpg" width="19" height="50"
>
> It works but I found the other important problem. This is image. What
> happend when I change the language ? Nothing cause this is permanent
> image and text "Move" is replaced by image
>
> So what should I do to change design of the button without using image ?
>
> Thanks a lot for an answers

You can also change the image with PHP depending on the user connecting
or which language he/she has chosen.

But for that you would have to create an image for each language.

I also think CSS will be the easiest solution.

http://www.w3.org/Style/CSS/

Good luck!

Greets
        Barry

--
Smileys rule (cX.x)C --o(^_^o)

attached mail follows:


David Grant wrote:
> Peter,
>
> You need to investigate CSS.

I would hesitate to add he needs to investigate how to ask
decent questions. (Peter your question lacks context, useful details,
a clear problem/question and a direct relevance to php)

and given the statement "default php grey button" I get
the impression that Peter doesn't really know what php or html
is; 'webmail' is a concept not an implementation.

I'm guessing Peter is trying to figure out how to change a
button in such a way that the button is/remains locale aware (i.e.
'Move' becomes something else when you change languages in the app
from english to something else)

so what's Peter using for his webmail? squirrelMail? or Horde's IMP?
or something else?

>
> David
>
> Jevos, Peter wrote:
>
>>Hi all
>>
>>I'd like to ask you one ( probably ) simple question. I'm using webmail
>>and I want to use other than default php grey button.
>>I found on the pages how to use image instead of the default button. So
>>I changed
>>
>>INPUT TYPE="submit" NAME="move_button" VALUE="Move"
>>
>>to
>>
>>INPUT TYPE="image'" NAME="move_button" VALUE="Move"
>>SRC="../images/button.jpg" width="19" height="50"
>>
>>It works but I found the other important problem. This is image. What
>>happend when I change the language ? Nothing cause this is permanent
>>image and text "Move" is replaced by image
>>
>>So what should I do to change design of the button without using image ?
>>
>>Thanks a lot for an answers
>>
>
>
>

attached mail follows:


Dear Jochem,

Thanks a lot for your answer
You're right, I know how to change bgcolor in html or set something like
this.
I'm using Squirrelmail and I need to change its layout. I set some
backgrounds color, fonts and this elemtary things.
I need to change design of buttons. All I need is some clear example and
I will adapt it

Thanks in advance

Pet

Peter Jevos peter.jevosoriflame-sw.com
Oriflame Software , s.r.o - Oriflame IT services
Na Pankraci 30, Praha 4, Czech rep.
Tel. +420 225 994 456, Fax +420225994412
-----Original Message-----
From: Jochem Maas [mailto:jochemiamjochem.com]
Sent: Monday, January 30, 2006 4:21 PM
To: David Grant
Cc: Jevos, Peter; php-generallists.php.net
Subject: Re: [PHP] Other than default grey button

David Grant wrote:
> Peter,
>
> You need to investigate CSS.

I would hesitate to add he needs to investigate how to ask decent
questions. (Peter your question lacks context, useful details, a clear
problem/question and a direct relevance to php)

and given the statement "default php grey button" I get the impression
that Peter doesn't really know what php or html is; 'webmail' is a
concept not an implementation.

I'm guessing Peter is trying to figure out how to change a button in
such a way that the button is/remains locale aware (i.e.
'Move' becomes something else when you change languages in the app from
english to something else)

so what's Peter using for his webmail? squirrelMail? or Horde's IMP?
or something else?

>
> David
>
> Jevos, Peter wrote:
>
>>Hi all
>>
>>I'd like to ask you one ( probably ) simple question. I'm using
>>webmail and I want to use other than default php grey button.
>>I found on the pages how to use image instead of the default button.
>>So I changed
>>
>>INPUT TYPE="submit" NAME="move_button" VALUE="Move"
>>
>>to
>>
>>INPUT TYPE="image'" NAME="move_button" VALUE="Move"
>>SRC="../images/button.jpg" width="19" height="50"
>>
>>It works but I found the other important problem. This is image. What
>>happend when I change the language ? Nothing cause this is permanent
>>image and text "Move" is replaced by image
>>
>>So what should I do to change design of the button without using image
?
>>
>>Thanks a lot for an answers
>>
>
>
>

attached mail follows:


Jevos, Peter wrote:
> Hi all
>
> I'd like to ask you one ( probably ) simple question. I'm using webmail
> and I want to use other than default php grey button.
> I found on the pages how to use image instead of the default button. So
> I changed
>
> INPUT TYPE="submit" NAME="move_button" VALUE="Move"
>
> to
>
> INPUT TYPE="image'" NAME="move_button" VALUE="Move"
> SRC="../images/button.jpg" width="19" height="50"
>
> It works but I found the other important problem. This is image. What
> happend when I change the language ? Nothing cause this is permanent
> image and text "Move" is replaced by image
>
> So what should I do to change design of the button without using image ?

So you're saying that these 'buttons' aren't images created by php?
Then I'm guessing your question has nothing to do with php. Try a
html/css mailing list, or there is that little helper web site out there...

http://www.google.com/search?q=color+form+buttons

--
John C. Nichel IV
Programmer/System Admin (ÜberGeek)
Dot Com Holdings of Buffalo
716.856.9675
jnicheldotcomholdingsofbuffalo.com

attached mail follows:


Jevos, Peter wrote:
> Dear Jochem,
>
> Thanks a lot for your answer

not often I get thanked for ranting (well psuedo-rant, if you
had said 'my client demands it, tell me now, it's urgent' at the end of your
post it would really have been a rant ;-)

> You're right, I know how to change bgcolor in html or set something like
> this.

not everyone is a programmer - but this mailinglist is really for
people who are programming in php at some/any level. (then again the
accepted relevancy level for this list is something like: "did X occur
within the confines of our own galaxy? yes? oh well then it's relevant
to php-general"

> I'm using Squirrelmail and I need to change its layout. I set some
> backgrounds color, fonts and this elemtary things.
> I need to change design of buttons. All I need is some clear example and
> I will adapt it

this is probably as good as it gets:
http://www.squirrelmail.org/wiki/CustomizingSquirrelMail

>
> Thanks in advance
>
> Pet
>
> Peter Jevos peter.jevosoriflame-sw.com
> Oriflame Software , s.r.o - Oriflame IT services
> Na Pankraci 30, Praha 4, Czech rep.
> Tel. +420 225 994 456, Fax +420225994412
> -----Original Message-----
> From: Jochem Maas [mailto:jochemiamjochem.com]
> Sent: Monday, January 30, 2006 4:21 PM
> To: David Grant
> Cc: Jevos, Peter; php-generallists.php.net
> Subject: Re: [PHP] Other than default grey button
>
> David Grant wrote:
>
>>Peter,
>>
>>You need to investigate CSS.
>
>
> I would hesitate to add he needs to investigate how to ask decent
> questions. (Peter your question lacks context, useful details, a clear
> problem/question and a direct relevance to php)
>
> and given the statement "default php grey button" I get the impression
> that Peter doesn't really know what php or html is; 'webmail' is a
> concept not an implementation.
>
>
> I'm guessing Peter is trying to figure out how to change a button in
> such a way that the button is/remains locale aware (i.e.
> 'Move' becomes something else when you change languages in the app from
> english to something else)
>
> so what's Peter using for his webmail? squirrelMail? or Horde's IMP?
> or something else?
>
>
>
>>David
>>
>>Jevos, Peter wrote:
>>
>>
>>>Hi all
>>>
>>>I'd like to ask you one ( probably ) simple question. I'm using
>>>webmail and I want to use other than default php grey button.
>>>I found on the pages how to use image instead of the default button.
>>>So I changed
>>>
>>>INPUT TYPE="submit" NAME="move_button" VALUE="Move"
>>>
>>>to
>>>
>>>INPUT TYPE="image'" NAME="move_button" VALUE="Move"
>>>SRC="../images/button.jpg" width="19" height="50"
>>>
>>>It works but I found the other important problem. This is image. What
>>>happend when I change the language ? Nothing cause this is permanent
>>>image and text "Move" is replaced by image
>>>
>>>So what should I do to change design of the button without using image
>
> ?
>
>>>Thanks a lot for an answers
>>>
>>
>>
>>
>

attached mail follows:


Dear Jochem
.
I know that I'm probably out of this mailing list.
I did almost everything , just buttons remains. I looked at the scripts,
it is php and I tried to change something but unsuccesfull.
Therefore I wrote to this mailing list, cause I thought this is matter
of php
I visited http://www.squirrelmail.org/wiki/CustomizingSquirrelMail but
it is not enough for me it is about colors, fonts and so on.

BR
Peter

Peter Jevos peter.jevosoriflame-sw.com
Oriflame Software , s.r.o - Oriflame IT services
Na Pankraci 30, Praha 4, Czech rep.
Tel. +420 225 994 456, Fax +420225994412
-----Original Message-----
From: Jochem Maas [mailto:jochemiamjochem.com]
Sent: Monday, January 30, 2006 4:43 PM
To: Jevos, Peter
Cc: David Grant; php-generallists.php.net
Subject: Re: [PHP] Other than default grey button

Jevos, Peter wrote:
> Dear Jochem,
>
> Thanks a lot for your answer

not often I get thanked for ranting (well psuedo-rant, if you had said
'my client demands it, tell me now, it's urgent' at the end of your post
it would really have been a rant ;-)

> You're right, I know how to change bgcolor in html or set something
> like this.

not everyone is a programmer - but this mailinglist is really for people
who are programming in php at some/any level. (then again the accepted
relevancy level for this list is something like: "did X occur within the
confines of our own galaxy? yes? oh well then it's relevant to
php-general"

> I'm using Squirrelmail and I need to change its layout. I set some
> backgrounds color, fonts and this elemtary things.
> I need to change design of buttons. All I need is some clear example
> and I will adapt it

this is probably as good as it gets:
http://www.squirrelmail.org/wiki/CustomizingSquirrelMail

>
> Thanks in advance
>
> Pet
>
> Peter Jevos peter.jevosoriflame-sw.com Oriflame Software , s.r.o -
> Oriflame IT services Na Pankraci 30, Praha 4, Czech rep.
> Tel. +420 225 994 456, Fax +420225994412 -----Original Message-----
> From: Jochem Maas [mailto:jochemiamjochem.com]
> Sent: Monday, January 30, 2006 4:21 PM
> To: David Grant
> Cc: Jevos, Peter; php-generallists.php.net
> Subject: Re: [PHP] Other than default grey button
>
> David Grant wrote:
>
>>Peter,
>>
>>You need to investigate CSS.
>
>
> I would hesitate to add he needs to investigate how to ask decent
> questions. (Peter your question lacks context, useful details, a clear

> problem/question and a direct relevance to php)
>
> and given the statement "default php grey button" I get the impression

> that Peter doesn't really know what php or html is; 'webmail' is a
> concept not an implementation.
>
>
> I'm guessing Peter is trying to figure out how to change a button in
> such a way that the button is/remains locale aware (i.e.
> 'Move' becomes something else when you change languages in the app
> from english to something else)
>
> so what's Peter using for his webmail? squirrelMail? or Horde's IMP?
> or something else?
>
>
>
>>David
>>
>>Jevos, Peter wrote:
>>
>>
>>>Hi all
>>>
>>>I'd like to ask you one ( probably ) simple question. I'm using
>>>webmail and I want to use other than default php grey button.
>>>I found on the pages how to use image instead of the default button.
>>>So I changed
>>>
>>>INPUT TYPE="submit" NAME="move_button" VALUE="Move"
>>>
>>>to
>>>
>>>INPUT TYPE="image'" NAME="move_button" VALUE="Move"
>>>SRC="../images/button.jpg" width="19" height="50"
>>>
>>>It works but I found the other important problem. This is image. What

>>>happend when I change the language ? Nothing cause this is permanent
>>>image and text "Move" is replaced by image
>>>
>>>So what should I do to change design of the button without using
>>>image
>
> ?
>
>>>Thanks a lot for an answers
>>>
>>
>>
>>
>

attached mail follows:


Silvio Porcellana [tradeOver] wrote:
> Barry wrote:
>
>> Simple reg help please
>>
>> i want to match the last "," in "a,b,c,d" and replace it with " and "
>>
>
> Without using a regexp, you could do:
>
> <code>
> $string = 'a,b,c,d';
> $letters = explode(',', $string);
> $last_letter = array_pop($letters);
> $final_string = implode(',', $letters) . ' and ' . $last_letter;
> </code>
>
> Not very efficient - but should work...
>
> Silvio
>

Nah found a solution ^^

My regular expression is as follows: ereg_replace
(",([[:alnum:][:space:]]*)$"," and \\1",$string)

Thanks for the help =)
Note: that expression does not work with string who have other signs
than "," in it e.g. "!" or "?".

Barry

--
Smileys rule (cX.x)C --o(^_^o)