php-general Digest 16 Sep 2009 06:38:32 -0000 Issue 6342

Topics (messages 298067 through 298085):

Re: PHP GURU NEEDED
        298067 by: Jay Blanchard

Re: php.ini in cgi vs php.ini in cli
        298068 by: Andres Gonzalez
        298069 by: Lars Torben Wilson

moving to quad core
        298070 by: Andres Gonzalez
        298071 by: Robert Cummings
        298072 by: Tom Worster
        298074 by: Rahul S. Johari
        298077 by: Eddie Drapkin
        298082 by: Clancy

Problem with date
        298073 by: Korgan
        298075 by: Jonathan Tapicer
        298076 by: Mayer, Jonathan

php/mysql  Query Question.
        298078 by: admin.buskirkgraphics.com
        298079 by: Robert Cummings
        298083 by: Robert Cummings

best function to use ~ file_get_contents or ?
        298080 by: CRM
        298084 by: Tommy Pham
        298085 by: Gaurav Kumar

Re: anyone interested in PHP? Call for moderator
        298081 by: Clancy

Administrivia:

To subscribe to the digest, e-mail:
        [email protected]

To unsubscribe from the digest, e-mail:
        [email protected]

To post to the list, e-mail:
        [email protected]


----------------------------------------------------------------------
--- Begin Message ---
[snip]
...
[/snip]

Gentlemen...take this offline.

--- End Message ---
--- Begin Message ---
Lars,

Thank you for your response. The function that raised this error is from my own extension module. I was not aware of phpinfo() and your suggestion to run it helped me resolve this issue. Turns out my CGI version is NOT using cgi/php.ini but is using
apache2/php.ini instead.

Thanks again for your help--you deserve a raise. :-)

-Andres





Lars Torben Wilson wrote:
On Mon, 14 Sep 2009 18:21:11 -0400
Andres Gonzalez <[email protected]> wrote:

In the php configurations directories /etc/php5, there are 2 subdirectories, one for
cgi and one for cli.  There is a php.ini file in each of these
directories.

What would cause a difference of behavior in these 2 environments
with the php.ini
exactly the same in each directory??

I have a command line script that consequently uses the cli version. This script works
just fine in that it can access API function in modules that are
loaded via cli/php.ini

However, when executing in the cgi environment, I get a "call to undefined function" error
even though my 2 php.ini files are exactly the same.

Any idea what is causing this?

thanks,

-Andres


Hi Andres,

When asking this kind of question, it would be very helpful if you
would tell us *which* function raised this error.

My first thought is that you tried to call a function which was
compiled in to the CLI version but not the CGI. What does phpinfo()
show when run under each?


Torben


--- End Message ---
--- Begin Message ---
On Tue, 15 Sep 2009 10:11:56 -0400
Andres Gonzalez <[email protected]> wrote:

> Lars,
> 
> Thank you for your response. The function that raised this error is
> from my own
> extension module. I was not aware of phpinfo() and your suggestion to 
> run it helped
> me resolve this issue. Turns out my CGI version is NOT using
> cgi/php.ini but is using
> apache2/php.ini instead.
> 
> Thanks again for your help--you deserve a raise. :-)
> 
> -Andres

Hi Andres,

Glad it worked! 


Regards,

Torben

> Lars Torben Wilson wrote:
> > On Mon, 14 Sep 2009 18:21:11 -0400
> > Andres Gonzalez <[email protected]> wrote:
> >
> >   
> >> In the php configurations directories /etc/php5, there are 2 
> >> subdirectories, one for
> >> cgi and one for cli.  There is a php.ini file in each of these
> >> directories.
> >>
> >> What would cause a difference of behavior in these 2 environments
> >> with the php.ini
> >> exactly the same in each directory??
> >>
> >> I have a command line script that consequently uses the cli
> >> version. This script works
> >> just fine in that it can access API function in modules that are
> >> loaded via cli/php.ini
> >>
> >> However, when executing in the cgi environment, I get a "call to 
> >> undefined function" error
> >> even though my 2 php.ini files are exactly the same.
> >>
> >> Any idea what is causing this?
> >>
> >> thanks,
> >>
> >> -Andres
> >>
> >>     
> >
> > Hi Andres,
> >
> > When asking this kind of question, it would be very helpful if you
> > would tell us *which* function raised this error.
> >
> > My first thought is that you tried to call a function which was
> > compiled in to the CLI version but not the CGI. What does phpinfo()
> > show when run under each?
> >
> >
> > Torben
> >
> >   


--- End Message ---
--- Begin Message --- I have an application developed that uses alot of PHP. Currently, it is running on a Ubuntu 8.04 , single core CPU host. We are moving to a quad core host for this application.

Is there anything special that I need to do to configure PHP to run on a quad core host? I noticed that my current single core system has PHP configured with Thread Safety disabled (as reported from phpinfo()). Does that need to be enabled to run in a multi-core environment?

Any other suggestions for configuring PHP for multi-core use?

Thanks,

-Andres

--- End Message ---
--- Begin Message ---
Andres Gonzalez wrote:
I have an application developed that uses alot of PHP. Currently, it is running on a Ubuntu 8.04 , single core CPU host. We are moving to a quad core host for this application.

Is there anything special that I need to do to configure PHP to run on a quad core host? I noticed that my current single core system has PHP configured with Thread Safety disabled (as reported from phpinfo()). Does that need to be enabled to run in a multi-core environment?

Any other suggestions for configuring PHP for multi-core use?

You don't need to change anything.

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

--- End Message ---
--- Begin Message ---
On 9/15/09 10:54 AM, "Andres Gonzalez" <[email protected]> wrote:

> I have an application developed that uses alot of PHP. Currently, it is
> running on a Ubuntu 8.04 , single core CPU host.  We are moving to a
> quad core host for this application.
> 
> Is there anything special that I need to do to configure PHP to run on a
> quad core host? I noticed that my current single core system has PHP
> configured with Thread Safety disabled (as reported from phpinfo()).
> Does that need to be enabled to run in a multi-core environment?
> 
> Any other suggestions for configuring PHP for multi-core use?

interesting question.

i never paid any attention to the possibility of needing to make config
changes when moving from single to multi-core computers. i'm using apxs2 and
just assumed that there's no threading within each httpd process. in other
words, i assumed it's up to the os' scheduler to make something of the
hardware.

i'm curious to hear more on the topic.



--- End Message ---
--- Begin Message ---

On 9/15/09 10:54 AM, "Andres Gonzalez" <[email protected]> wrote:


I have an application developed that uses alot of PHP. Currently, it is
running on a Ubuntu 8.04 , single core CPU host.  We are moving to a
quad core host for this application.

Is there anything special that I need to do to configure PHP to run on a
quad core host? I noticed that my current single core system has PHP
configured with Thread Safety disabled (as reported from phpinfo()).
Does that need to be enabled to run in a multi-core environment?

Any other suggestions for configuring PHP for multi-core use?


Very interesting question indeed;

I moved from a single-core to dual-core some time back, and recently moved from dual-core to quad-core. Never paid attention to the hyper- threading difference in the httpd process. Would definitely be interesting in seeing more information on this topic.

---
Rahul Sitaram Johari
Founder, Internet Architects Group, Inc.

[Email] [email protected]
[Web]   http://www.rahulsjohari.com





--- End Message ---
--- Begin Message ---
On Tue, Sep 15, 2009 at 11:35 AM, Rahul S. Johari
<[email protected]> wrote:
>
>> On 9/15/09 10:54 AM, "Andres Gonzalez" <[email protected]> wrote:
>>
>>>
>> I have an application developed that uses alot of PHP. Currently, it is
>> running on a Ubuntu 8.04 , single core CPU host.  We are moving to a
>> quad core host for this application.
>>
>> Is there anything special that I need to do to configure PHP to run on a
>> quad core host? I noticed that my current single core system has PHP
>> configured with Thread Safety disabled (as reported from phpinfo()).
>> Does that need to be enabled to run in a multi-core environment?
>>
>> Any other suggestions for configuring PHP for multi-core use?
>
>
> Very interesting question indeed;
>
> I moved from a single-core to dual-core some time back, and recently moved
> from dual-core to quad-core. Never paid attention to the hyper-threading
> difference in the httpd process. Would definitely be interesting in seeing
> more information on this topic.
>
> ---
> Rahul Sitaram Johari
> Founder, Internet Architects Group, Inc.
>
> [Email] [email protected]
> [Web]   http://www.rahulsjohari.com
>
>
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

In regards to thread-safe compilations of PHP, if you don't absolutely
know you need it, you don't need it.

Utilizing a multiple CPU server setup with PHP depends on how you're
using PHP.  If you're using FastCGI with a process pool, the number of
PHP processes is going to determine how many CPUs PHP uses, obviously
enough.  On a quad core machine, 2 FastCGI children in the pool are
only ever going to use 2 cores, while 4 processes has a higher
likelihood of utilizing the entire set of CPUs.  However, setting your
child process number too low can seriously impede your performance, so
there's some experimentation necessary to determine what's best for
your particular scenario, based on usage, server power, script
profiling, etc. but a good number to start with is (1.5 * # of logical
processors).

All of this necessarily changes if you're using Apache, of course.
Under the classic pre-fork model, Apache forks a new process to handle
a request every time the server is hit.  So, to utilize four cores,
Apache would have to serve four pages simultaneously, forking four
child processes.  Depending on your traffic and page generation time,
the amount of child Apache processes can pretty easily head up into
the hundreds, unless of course you have a lower MaxChildren set (which
I personally would recommend against because of Apache's huge glaring
vulnerability to SlowLoris).  Under the worker model, Apache forks up
to X processes, and each process handles a configurable amount of
requests before dying, so like FastCGI, you'd have to configure the
number of children to be run, although it's recommended (I hear, I'm
not too very familiar with Apache) to use a much higher number than
the amount of cores, several dozen perhaps.  Like I said, I'm not too
familiar with Apache, so I'd do some research and experimentation with
the number of child workers to give Apache.

I hope this helps :)

--- End Message ---
--- Begin Message ---
On Tue, 15 Sep 2009 11:55:51 -0400, [email protected] (Eddie Drapkin) wrote:

>On Tue, Sep 15, 2009 at 11:35 AM, Rahul S. Johari
><[email protected]> wrote:
>>
........
>the amount of cores, several dozen perhaps.  Like I said, I'm not too
>familiar with Apache, so I'd do some research and experimentation with
>the number of child workers to give Apache.

First we have people worrying about losing their jobs to kindergarten children, 
now we
have people recommending giving Apache child workers. Call out the RSPCC!


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

 I have a problem with date function.

$gen_pos = mktime(0,0,1,10,25,2009);
$d1 = date("Y-m-d", $gen_pos);              // 2009-10-25
$d2 = date("Y-m-d", $gen_pos + (1*24*60*60)); // 2009-10-25
$d3 = date("Y-m-d", $gen_pos + (2*24*60*60)); // 2009-10-26
$d4 = date("Y-m-d", $gen_pos + (3*24*60*60)); // 2009-10-27
$d5 = date("Y-m-d", $gen_pos + (4*24*60*60));
$d6 = date("Y-m-d", $gen_pos + (5*24*60*60));
$d7 = date("Y-m-d", $gen_pos + (6*24*60*60));
$d8 = date("Y-m-d", $gen_pos + (7*24*60*60));

line 2 and line 3 return same date,its wrong ... it should be 2009-10-25 , 2009-10-26 ? :)
--- End Message ---
--- Begin Message ---
Adding the number of seconds in a day could fall in the same day due
to daylight saving time, a more reliable way of adding one day (or a
given number of days) is this:

$tomorrow  = mktime(0, 0, 0, date("m")  , date("d")+1, date("Y"));

Then use date() with $tomorrow to format it.

(Taken from example #3 here:
http://www.php.net/manual/en/function.date.php, see the Note below the
example in that page).

Hope that helps.

Regards,
Jonathan


2009/9/15 Korgan <[email protected]>:
> Hi,
>
>  I have a problem with date function.
>
> $gen_pos = mktime(0,0,1,10,25,2009);
> $d1 = date("Y-m-d", $gen_pos);                // 2009-10-25
> $d2 = date("Y-m-d", $gen_pos + (1*24*60*60)); // 2009-10-25
> $d3 = date("Y-m-d", $gen_pos + (2*24*60*60)); // 2009-10-26
> $d4 = date("Y-m-d", $gen_pos + (3*24*60*60)); // 2009-10-27
> $d5 = date("Y-m-d", $gen_pos + (4*24*60*60));
> $d6 = date("Y-m-d", $gen_pos + (5*24*60*60));
> $d7 = date("Y-m-d", $gen_pos + (6*24*60*60));
> $d8 = date("Y-m-d", $gen_pos + (7*24*60*60));
>
> line 2 and line 3 return same date,its wrong ... it should be 2009-10-25 ,
> 2009-10-26 ? :)
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--- End Message ---
--- Begin Message ---
strtotime would be a neater way of solving the problem...

ie (untested):

$n = 0;
while ($n <= 9)
{
        $date = "d".$n;
        $$date = date("Y-m-d", strtotime("+ $n days")
        $n++;
}

If you are just enquiring about the maths though, I'm not sure!

-----Original Message-----
From: Korgan [mailto:[email protected]] 
Sent: 15 September 2009 16:32
To: [email protected]
Subject: [PHP] Problem with date

Hi,

  I have a problem with date function.

$gen_pos = mktime(0,0,1,10,25,2009);
$d1 = date("Y-m-d", $gen_pos);                // 2009-10-25
$d2 = date("Y-m-d", $gen_pos + (1*24*60*60)); // 2009-10-25
$d3 = date("Y-m-d", $gen_pos + (2*24*60*60)); // 2009-10-26
$d4 = date("Y-m-d", $gen_pos + (3*24*60*60)); // 2009-10-27
$d5 = date("Y-m-d", $gen_pos + (4*24*60*60));
$d6 = date("Y-m-d", $gen_pos + (5*24*60*60));
$d7 = date("Y-m-d", $gen_pos + (6*24*60*60));
$d8 = date("Y-m-d", $gen_pos + (7*24*60*60));

line 2 and line 3 return same date,its wrong ... it should be 2009-10-25

, 2009-10-26 ? :)

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




--- End Message ---
--- Begin Message ---
Before most of you go on a rampage of how to please read below...

As most of you already know when using MySQL from the shell you can write your 
queries in html format in an out file.

Example:   shell>mysql -uyourmom -plovesme --html
This now will return all results in an html format from all queries.

Now I could “tee” this to a file and save the results returned if I so choose 
to save the result of the display .

Let’s say I want to be lazy and write a php MySQL query to do the same so that 
any result I queried for would return the html results in a table without 
actually writing the table tags in the results.

Is there a mysql_connect or select_db or mysql_query tag option to do that 
since mysql can display it from the shell?

--- End Message ---
--- Begin Message ---


[email protected] wrote:
Before most of you go on a rampage of how to please read below...

As most of you already know when using MySQL from the shell you can write your 
queries in html format in an out file.

Example:   shell>mysql -uyourmom -plovesme --html
This now will return all results in an html format from all queries.

Now I could “tee” this to a file and save the results returned if I so choose 
to save the result of the display .

Let’s say I want to be lazy and write a php MySQL query to do the same so that 
any result I queried for would return the html results in a table without 
actually writing the table tags in the results.

Is there a mysql_connect or select_db or mysql_query tag option to do that 
since mysql can display it from the shell?

echo "Select * from my_table" | mysql --html -ufoo -pfee database_name

However, this allows for your database password to be visible in the process list for a brief moment of time. You might be better served by finer grained process control where you can check the output and provide input as needed. Or a simple expect script might suffice.

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

--- End Message ---
--- Begin Message ---
[email protected] wrote:
Would you mind giving me an example of this that i can stick right into a blank 
php file and run.

I get what you are saying but i cant seem to make that even echo out the data.  
php 5.2 mysql 5.1.3 Apache 2.2

<?php

$db   = 'db';
$host = 'host';
$user = 'user';
$pass = 'pass';

$query = "select * from my_table";

$db   = escapeShellArg( $db );
$host = escapeShellArg( $host );
$user = escapeShellArg( $user );
$pass = escapeShellArg( $pass );

$query = escapeShellArg( $query );

$command = "echo $query | mysql --html -h$host -u$user -p$pass $db";

echo 'Command: '.$command."\n";
$html = `$command`;
echo $html."\n";

?>

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


--- End Message ---
--- Begin Message ---
Hi All,
Not sure of the best approach, need your feedback. I have 4 images on a
website. These are used in navigation. When I load a reference webpage on my
local machine the local page calls 4 images from an external website, each
image will be on a different domain.

What I want to see is if the navigation images/buttons can be loaded/displayed
in my browser. If they can, then I will display the images on my local page.
If the images cannot be loaded, then this indicates some connection issue and
the result will be some text like 'Site Offline'. So just by glancing at my
local machine reference page I can tell if one or more of the different sites
is or is not available.

So what is the best function to use?

if ( @file_get_contents( DOMAIN_PATH . "images/navigation/nav_globalissa.png" 
)):

or ???

Please also cc [email protected]

Thanks for any helpful suggestions.

Sincerely,

Rob
Global I.S. S.A.
Software Powers the Net
Email: crm at globalissa dot com

* * * The Forge of Globalissa ~ PHP Foobar Machine * * *
http://globalissa.com/forge/


--- End Message ---
--- Begin Message ---
--- On Tue, 9/15/09, CRM <[email protected]> wrote:

> From: CRM <[email protected]>
> Subject: [PHP] best function to use ~ file_get_contents or ?
> To: [email protected]
> Cc: [email protected]
> Date: Tuesday, September 15, 2009, 5:36 PM
> Hi All,
> Not sure of the best approach, need your feedback. I have 4
> images on a
> website. These are used in navigation. When I load a
> reference webpage on my
> local machine the local page calls 4 images from an
> external website, each
> image will be on a different domain.
> 
> What I want to see is if the navigation images/buttons can
> be loaded/displayed
> in my browser. If they can, then I will display the images
> on my local page.
> If the images cannot be loaded, then this indicates some
> connection issue and
> the result will be some text like 'Site Offline'. So just
> by glancing at my
> local machine reference page I can tell if one or more of
> the different sites
> is or is not available.
> 
> So what is the best function to use?
> 
> if ( @file_get_contents( DOMAIN_PATH .
> "images/navigation/nav_globalissa.png" )):
> 
> or ???
> 
> Please also cc [email protected]
> 
> Thanks for any helpful suggestions.
> 
> Sincerely,
> 
> Rob
> Global I.S. S.A.
> Software Powers the Net
> Email: crm at globalissa dot com
> 
> * * * The Forge of Globalissa ~ PHP Foobar Machine * * *
> http://globalissa.com/forge/
> 
> 

Shouldn't it be:

if ( @file_get_contents( DOMAIN_PATH . 
 "images/navigation/nav_globalissa.png", FILE_BINARY))




--- End Message ---
--- Begin Message ---
There is no best function as such. Everything depends upon your requirement.

You can also use fopen() to get the contents of the remote file and do some
error handling that if you get any content then display image else a message
etc..

Gaurav Kumar
(Team Lead- open source)
oswebstudio.com



On Wed, Sep 16, 2009 at 4:06 AM, CRM <[email protected]> wrote:

> Hi All,
> Not sure of the best approach, need your feedback. I have 4 images on a
> website. These are used in navigation. When I load a reference webpage on
> my
> local machine the local page calls 4 images from an external website, each
> image will be on a different domain.
>
> What I want to see is if the navigation images/buttons can be
> loaded/displayed
> in my browser. If they can, then I will display the images on my local
> page.
> If the images cannot be loaded, then this indicates some connection issue
> and
> the result will be some text like 'Site Offline'. So just by glancing at my
> local machine reference page I can tell if one or more of the different
> sites
> is or is not available.
>
> So what is the best function to use?
>
> if ( @file_get_contents( DOMAIN_PATH .
> "images/navigation/nav_globalissa.png" )):
>
> or ???
>
> Please also cc [email protected]
>
> Thanks for any helpful suggestions.
>
> Sincerely,
>
> Rob
> Global I.S. S.A.
> Software Powers the Net
> Email: crm at globalissa dot com
>
> * * * The Forge of Globalissa ~ PHP Foobar Machine * * *
> http://globalissa.com/forge/
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--- End Message ---
--- Begin Message ---
On Tue, 15 Sep 2009 13:47:06 +0100, [email protected] (Ashley Sheridan) 
wrote:

>On Tue, 2009-09-15 at 13:45 +0100, Richard Heyes wrote:
>> Hi,
>> 
>> > It is good to hear that they teach PHP in kindergarden these days.
>> 
>> I've heard it's soon to be part of the national curriculum here in the UK.
>> 
>> -- 
>> Richard Heyes
>> HTML5 graphing: RGraph - www.rgraph.net (updated 5th September)
>> Lots of PHP and Javascript code - http://www.phpguru.org
>> 
>I hope not, I'm not having some toddler doing me out of a job!

It's been known for years that the essential accessory for any piece of modern 
electronics
equipment is a 10-year-old boy!


--- End Message ---

Reply via email to