php-general Digest 12 Jul 2006 01:17:05 -0000 Issue 4234

Topics (messages 239308 through 239331):

Re: Problems with caching and headers.
        239308 by: Mathijs
        239310 by: Mathijs
        239311 by: Jochem Maas
        239312 by: Mathijs
        239318 by: Jochem Maas

Re: printing special characters in PHP
        239309 by: tedd

Re: Problem installing php] - SOLVED
        239313 by: Ruben Rubio Rey

Re: Startinga shell process with a life of its own
        239314 by: John Gunther
        239331 by: Kevin Waterson

Re: I cannot forget you!
        239315 by: Robert Cummings

PHP 5....
        239316 by: Ryan A
        239319 by: Jochem Maas

Re: GD to database directly
        239317 by: Eric Butera
        239324 by: Adam Zey

order/reorder pull out data from arrays
        239320 by: Dallas Cahker
        239322 by: Jake Gardner
        239323 by: Jochem Maas

Re: ftp_put()'ing a string ...
        239321 by: Jochem Maas

How do I prevent a session from rebuilding itself?
        239325 by: Daevid Vincent

PHP 5...
        239326 by: Ryan A
        239327 by: Daevid Vincent
        239328 by: Rory Browne

DB Create Table help - using Pear DB
        239329 by: Scott Heinrichs
        239330 by: tedd

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 ---
Jochem Maas wrote:
Mathijs wrote:
Mathijs wrote:
Jochem Maas wrote:
Mathijs wrote:
Hello there,

I can't figure out why there are some headers set while i don't set
them
myself.

The following headers are sent to the browser.
-Expires: Thu, 19 Nov 1981 08:52:00 GMT
-Cache-Control: no-store, no-cache, must-revalidate, post-check=0,
pre-check=0
-Pragma: no-cache

All those i didn't set my self.

Does PHP set these or something?
maybe it was php (check your session settings and read the relevant
parts of the manual
regarding session related headers)

maybe it was a piece of 3rd party code.

may it was 'something' ;-)

most likely it's the session extension doing this.

And you are right again :).
Thanks again.

This was a real pain in the ass.
Because IE didn't sent the If-Last-Modified and/or if-none-match if
one of those headers are sent.

Thank you.


Thx in advanced.

Well it seems its working kinda.

Now i have a problem with the ETag.

what are you using this header for?

I Use this header to check if the content of a file has changed.
This because the content can be variable. But is static most of the time.

I Compute an MD5 of the content, and add this to the ETag.
Normally a browser sends an HTTP_IF_NONE_MATCH back if it has an ETag.
If this gets send back, i compare them and if they are the same, they get en 
304 Not Modified back.

Now Internet Explorer doesn't send this back when the content has been 
compressed (gz_handler).
This because the Vary header has been set or something.
This is a bug in IE, and probably fixed in IE7.



Internet Explorer seems to forget this when the content is compressed.
This because of the Vary header apparently.

Is there a fix for this?
Or a workaround?

yes. but your no longer in the realm of php (I believe)
this is something you should tackle at the webserver configuration level...

on one of the machines I run the (main) site has this in the config (its 
apache):

# Netscape 4.x has some problems...
BrowserMatch            ^Mozilla/4 gzip-only-text/html
# Netscape              4.06-4.08 have some more problems
BrowserMatch            ^Mozilla/4\.0[678] no-gzip
# MSIE masquerades as Netscape, but it is fine
BrowserMatch            \bMSIE !no-gzip !gzip-only-text/html
# NOTE: Due to a bug in mod_setenvif up to Apache 2.0.48
# the above regex won't work. You can use the following
# workaround to get the desired effect:
BrowserMatch            \bMSI[E] !no-gzip !gzip-only-text/html
# Don't compress images
SetEnvIfNoCase          Request_URI \.(?:gif|jpe?g|png)$ no-gzip dont-vary
SetEnvIfNoCase          Request_URI \/image\.php no-gzip dont-vary
# Also don't compress PDF and Flash-files 17-01-2004 MM
SetEnvIfNoCase          Request_URI \.pdf$ no-gzip dont-vary
SetEnvIfNoCase          Request_URI \.swf$ no-gzip dont-vary
# Make sure proxies don't deliver the wrong content
Header                  append Vary User-Agent env=!dont-vary

now I'm not saying these settings will work for you - the site in question
runs behind an instance of Squid configured as a reverse caching proxy - which
complicates matters somewhat - but it might give you an idea.

I have checked this also, and it came up with nothing. :(.

It now seems that i have to check if i am dealing with Internet Explorer or not 
within PHP.
And then if it is IE i don't compress the content.


Anyway,
Thank you very much for your help :).
If you have any idea's left :D.

Kind Regards,
Mathijs.


Thx.



---
avast! Antivirus: Outbound message clean.
Virus Database (VPS): 0628-1, 07-10-2006
Tested on: 07-11-2006 13:33:12
avast! - copyright (c) 1988-2006 ALWIL Software.
http://www.avast.com






---
avast! Antivirus: Outbound message clean.
Virus Database (VPS): 0628-1, 07-10-2006
Tested on: 07-11-2006 14:47:23
avast! - copyright (c) 1988-2006 ALWIL Software.
http://www.avast.com

--- End Message ---
--- Begin Message ---
Mathijs wrote:
Jochem Maas wrote:
Mathijs wrote:
Hello there,

I can't figure out why there are some headers set while i don't set them
myself.

The following headers are sent to the browser.
-Expires: Thu, 19 Nov 1981 08:52:00 GMT
-Cache-Control: no-store, no-cache, must-revalidate, post-check=0,
pre-check=0
-Pragma: no-cache

All those i didn't set my self.

Does PHP set these or something?

maybe it was php (check your session settings and read the relevant parts of the manual
regarding session related headers)

maybe it was a piece of 3rd party code.

may it was 'something' ;-)

most likely it's the session extension doing this.


And you are right again :).
Thanks again.

This was a real pain in the ass.
Because IE didn't sent the If-Last-Modified and/or if-none-match if one of those headers are sent.

Thank you.


Thx in advanced.



Well it seems its working kinda.

Now i have a problem with the ETag.
Internet Explorer seems to forget this when the content is compressed.
This because of the Vary header apparently.

Is there a fix for this?
Or a workaround?

Thx.



---
avast! Antivirus: Outbound message clean.
Virus Database (VPS): 0628-1, 07-10-2006
Tested on: 07-11-2006 13:33:12
avast! - copyright (c) 1988-2006 ALWIL Software.
http://www.avast.com

--- End Message ---
--- Begin Message ---
Mathijs wrote:

...

>>>
>>> Now i have a problem with the ETag.
>>
>> what are you using this header for?
> 
> I Use this header to check if the content of a file has changed.
> This because the content can be variable. But is static most of the time.
> 
> I Compute an MD5 of the content, and add this to the ETag.
> Normally a browser sends an HTTP_IF_NONE_MATCH back if it has an ETag.
> If this gets send back, i compare them and if they are the same, they
> get en 304 Not Modified back.
> 
> Now Internet Explorer doesn't send this back when the content has been
> compressed (gz_handler).
> This because the Vary header has been set or something.
> This is a bug in IE, and probably fixed in IE7.
> 

freaking lightbulb moment for me!!! see how it pays to help people - you never 
know
when you might get slapped in the face with some new knowledge :-) thanks!

that said I wonder whether generating the dynamic content, buffering it, using 
the buffer to
generate a md5 hash and then checking that is any faster than just outputting 
the
generating content regardless? or is this purely a tactic to reduce bandwidth?

--- End Message ---
--- Begin Message ---
Jochem Maas wrote:
Mathijs wrote:

...

Now i have a problem with the ETag.
what are you using this header for?
I Use this header to check if the content of a file has changed.
This because the content can be variable. But is static most of the time.

I Compute an MD5 of the content, and add this to the ETag.
Normally a browser sends an HTTP_IF_NONE_MATCH back if it has an ETag.
If this gets send back, i compare them and if they are the same, they
get en 304 Not Modified back.

Now Internet Explorer doesn't send this back when the content has been
compressed (gz_handler).
This because the Vary header has been set or something.
This is a bug in IE, and probably fixed in IE7.


freaking lightbulb moment for me!!! see how it pays to help people - you never 
know
when you might get slapped in the face with some new knowledge :-) thanks!

that said I wonder whether generating the dynamic content, buffering it, using 
the buffer to
generate a md5 hash and then checking that is any faster than just outputting 
the
generating content regardless? or is this purely a tactic to reduce bandwidth?

LoL. And no problem.

Um yea it's an bandwidth saving tactic.
This because the website has big traffic.
And it is mostly the JS and CSS files that are eating everything up.
If i compress them it saves a lot of bandwidth.

I Just discovered this problem with IE and the ETag :(.
I use Opera and Firefox my self. But didn't really checked this caching in IE.
And most of the users still use IE.

I Think i have to weigh the features.
The content isn't going to be changed that much.
Only when someone changes the language or if i change some constant values.

So i think i go for this solution since there is non so ever to fix this for IE.

I am going to check the user-agent.
If it is IE then i am not going to gzip the contents.
Everything else then IE will get the gziped contents.

This way the ETag gets send back, and i can respond with an 304 if it still is 
the same.
This should save bandwidth also. And it will only send out an un-compressed 
version just once.
And it will resend the content when it is changed (Which i think won't happen 
that much).

Again, thanks for you thoughts :).
(Hartelijk dank voor de hulp :D ).

Mathijs

--- End Message ---
--- Begin Message ---
Mathijs wrote:
> Jochem Maas wrote:
>> Mathijs wrote:

...

> (Hartelijk dank voor de hulp :D ).

we kunnen geheime taal gaan gebruiken - vinden ze hier vast leuk ;-)

> 
> Mathijs
> 

--- End Message ---
--- Begin Message ---
At 10:16 AM +0000 7/11/06, Antonio Bassinger wrote:
>Dear ALL,
>
>I've an binary file with special (non-printable) characters including '<'
>'/' & '>'. I retrieve this file from the database, into a variable
>$binaryFILE.
>
>I then copy the content to a temporary file, opened with handle $handle :
>
>
>if (!fwrite($handle, $binaryFILE)) {
>          echo "Failed to copy $bname...";
>      }
>      else
>      {
>          echo "Success";
>      }
>
>The file copies to a file on the filesystem correctly. However, if I try to
>print out the characters of this file on a browser, using
>
>echo $binaryFILE;
>
>the output isn't the same. The characters '<' and '>' and anything included
>within is not printed.
>
>I tried printing line by line, using:
>
>$binaryMS = explode("",$binaryMMS);
>foreach ($binaryFILE as $ii)
>{
> echo $ii;
>}
>
>However, no change in result.
>
>Do I print character by character? I shall appreciate any pointers on this
>problem.
>
>Many Thanks
>Antonio

Antonio:

The reason why you are not seeing the characters is that they are being 
grabbed-up by the browser as html code. In other words, you are injecting html 
into your web page.

Take a look at this:

http://www.weberdev.com/htmlentities

Now, pass your content through this function and then display.

tedd



-- 
------------------------------------------------------------------------------------
http://sperling.com  http://ancientstones.com  http://earthstones.com

--- End Message ---
--- Begin Message ---
Solved installing csv version.
Is it officially stable?
Do anyone know when is it going to be stable?

-------- Original Message --------
Subject:        [PHP] Problem installing php
Date:   Tue, 11 Jul 2006 12:04:18 +0200
From:   Ruben Rubio Rey <[EMAIL PROTECTED]>
To:     [email protected]



I have a problem when installing php. I have tried with different versions of apache (2.0.55 and 2.0.58) and php (5.1.4 and 5.1.2).

The problem still there (Same error in different versions)!!!

Note that I had installed apache 2.0.58 and php 5.1.4 before on this server. Problems began when tried to add -with-pspell --with-openssl at configure. ( I installed aspell). When I tried it, i was no able to install php again.

Any ideas or workarrounds will be appreciated.


Complete Information:
Configure:
./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-gettext --with-pgsql --enable-trac k-vars --enable-force-cgi-redirect --with-mime-magic -with-pspell --with-openssl

Server: CentOS release 4.3 (Final)
           2.6.9-34.0.1.ELsmp

/usr/local/src/php-5.1.2$ make install
Installing PHP SAPI module:       apache2handler
/usr/local/apache2/build/instdso.sh SH_LIBTOOL='/usr/local/apache2/build/libtool' libphp5.la /usr/local/apache2/modules /usr/local/apache2/build/libtool --mode=install cp libphp5.la /usr/local/apache2/modules/
cp .libs/libphp5.lai /usr/local/apache2/modules/libphp5.la
cp .libs/libphp5.a /usr/local/apache2/modules/libphp5.a
ranlib /usr/local/apache2/modules/libphp5.a
chmod 644 /usr/local/apache2/modules/libphp5.a
libtool: install: warning: remember to run `libtool --finish /usr/local/src/php-5.1.2/libs'
Warning!  dlname not found in /usr/local/apache2/modules/libphp5.la.
Assuming installing a .so rather than a libtool archive.
chmod 755 /usr/local/apache2/modules/libphp5.so
chmod: no se puede acceder a «/usr/local/apache2/modules/libphp5.so»: No existe el fichero o el directorio
apxs:Error: Command failed with rc=65536

Thanks in advance,
Ruben Rubio

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

--- End Message ---
--- Begin Message --- Great approach! Slicker'n snot. I added one enhancement: The shell script writss progress info to the database which the trigger page displays on entry.



Richard Lynch wrote:
I would recommend, however, that you re-structure things slightly so
that the Architecture is more like this:

User visits web page.
Page generates a database record of what needs to be done.
Page finished.


CRON JOB:
Look in task list of what needs doing, and do some of them.
Make sure only one job is done at a time, or whatever race conditions
are handled here.

I've done projects both ways, and always end up frustrated with the
"PHP attempts to background a process" and the "Task List + Cron"
always works out far far better.


--- End Message ---
--- Begin Message ---
This one time, at band camp, "Daevid Vincent" <[EMAIL PROTECTED]> wrote:
> 
> I wish PHP would add threading. We write enterprise level products with PHP,
> and we end up using DBUS and letting Ruby do all the "real work".

submit patch

Kevin

-- 
"Democracy is two wolves and a lamb voting on what to have for lunch. 
Liberty is a well-armed lamb contesting the vote."

--- End Message ---
--- Begin Message ---
On Tue, 2006-07-11 at 05:26, Barry wrote:
> [EMAIL PROTECTED] schrieb:
> > your big love, ;-)
> > 
> Well PHP is good .... but is it that good?

*sheeeesh* Where have you been?

http://marc.theaimsgroup.com/?l=php-general&m=115129593132595&w=2

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

--- End Message ---
--- Begin Message ---
Hi,
Something strange and dont really know what to expect so was hoping you more 
experienced PHP 5 people can help me out.

We have been given a development server thats running php5 with MySql Client 
API version 5.0.22 (didnt know there was one that high)

the problem is, we have to develop on this and then when its done the app will 
be moved to a php 4 final server...

I have been reading and i see that there are some php4 functions that act 
strange on php5 (like strpos)
are there any other things I should be aware of?

If you think it would be too much of a hassle, do you think i should request 
the admin to install php 4 instead and scrap this installation? 

I have also seen many sites having php4 and 5 on the same machine, this is a 
windows server, is there any easy way to do that here?

Thanks!
Ryan
 
------- The faulty interface lies between the chair and the keyboard.
- Creativity is great, but plagiarism is faster!
- Smile, everyone loves a moron. :-)


--- End Message ---
--- Begin Message ---
Ryan A wrote:
> Hi,
> Something strange and dont really know what to expect so was hoping you more 
> experienced PHP 5 people can help me out.

btw which minor version of php5 your running is important ... plenty of things 
have changed in [semi] breaking ways
between minor php5 versions.

> 
> We have been given a development server thats running php5 with MySql Client 
> API version 5.0.22 (didnt know there was one that high)
> 
> the problem is, we have to develop on this and then when its done the app 
> will be moved to a php 4 final server...
> 
> I have been reading and i see that there are some php4 functions that act 
> strange on php5 (like strpos)

what's wrong with strpos() in php5? are you perchance using multibyte strings 
without using the mb_string
function overloading stuff?

> are there any other things I should be aware of?

the fact that objects are always references in php5 and in php4 you have to use 
'&' everwhere to
make sure your always talking to the same object (using the '&' notation in 
php5 will give you NOTICEs or WARNINGS
depending on the minor version)

that and a million other little things like certain functions not being 
available :-)

> 
> If you think it would be too much of a hassle, do you think i should request 
> the admin to install php 4 instead and scrap this installation? 

YES. *at the very least* it will be a pain to dev on php5 and go to production 
on a php4.

> 
> I have also seen many sites having php4 and 5 on the same machine, this is a 
> windows server, is there any easy way to do that here?

sorry I'm clueless regardless IIS.

> 
> Thanks!
> Ryan
>  
> ------- The faulty interface lies between the chair and the keyboard.
> - Creativity is great, but plagiarism is faster!
> - Smile, everyone loves a moron. :-)
> 
> 

--- End Message ---
--- Begin Message ---
On 7/11/06, Kevin Waterson <[EMAIL PROTECTED]> wrote:

How much of  a performance hit?

Kevin

--
"Democracy is two wolves and a lamb voting on what to have for lunch.
Liberty is a well-armed lamb contesting the vote."

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



Here's to being bored on lunch. :)


Now to add my two cents to the convo:
I don't see a problem with storing images in the DB IF they aren't
going to be continually accessed that way.  For example say you have a
script that lets a user upload an image and creates a small, medium,
and large view out of it.  Stick the original in the Db and then make
your 3 sizes on the fly and cache the output so they are not
continually created.  This way you could down the road re-do all the
sizes if you go through a site redesign or the client chooses they
want them 450 instead of 400. =)


Via MySQL 4.1 & PHP 5.1.4:
erics:~ eric$ ab -n500 -c5 http://localhost/fs_vs_db/viewimage_db.php
This is ApacheBench, Version 1.3d <$Revision: 1.73 $> apache-1.3
Copyright (c) 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Copyright (c) 1998-2002 The Apache Software Foundation, http://www.apache.org/

Benchmarking localhost (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Finished 500 requests
Server Software:        Apache/1.3.33
Server Hostname:        localhost
Server Port:            80

Document Path:          /fs_vs_db/viewimage_db.php
Document Length:        25256 bytes

Concurrency Level:      5
Time taken for tests:   4.323 seconds
Complete requests:      500
Failed requests:        0
Broken pipe errors:     0
Total transferred:      12727000 bytes
HTML transferred:       12628000 bytes
Requests per second:    115.66 [#/sec] (mean)
Time per request:       43.23 [ms] (mean)
Time per request:       8.65 [ms] (mean, across all concurrent requests)
Transfer rate:          2944.02 [Kbytes/sec] received

Connnection Times (ms)
             min  mean[+/-sd] median   max
Connect:        0     0    0.4      0    10
Processing:    14    42   12.6     38   147
Waiting:       14    42   12.6     38   147
Total:         14    42   12.6     38   147

Percentage of the requests served within a certain time (ms)
 50%     38
 66%     40
 75%     44
 80%     46
 90%     56
 95%     67
 98%     78
 99%     97
100%    147 (last request)





Raw Image:
erics:~ eric$ ab -n500 -c5 http://localhost/fs_vs_db/cloud.jpg
This is ApacheBench, Version 1.3d <$Revision: 1.73 $> apache-1.3
Copyright (c) 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Copyright (c) 1998-2002 The Apache Software Foundation, http://www.apache.org/

Benchmarking localhost (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Finished 500 requests
Server Software:        Apache/1.3.33
Server Hostname:        localhost
Server Port:            80

Document Path:          /fs_vs_db/cloud.jpg
Document Length:        25256 bytes

Concurrency Level:      5
Time taken for tests:   0.624 seconds
Complete requests:      500
Failed requests:        0
Broken pipe errors:     0
Total transferred:      12775000 bytes
HTML transferred:       12628000 bytes
Requests per second:    801.28 [#/sec] (mean)
Time per request:       6.24 [ms] (mean)
Time per request:       1.25 [ms] (mean, across all concurrent requests)
Transfer rate:          20472.76 [Kbytes/sec] received

Connnection Times (ms)
             min  mean[+/-sd] median   max
Connect:        0     1    0.7      1     5
Processing:     3     5    6.6      4   131
Waiting:        1     4    6.7      3   130
Total:          3     6    6.5      5   131

Percentage of the requests served within a certain time (ms)
 50%      5
 66%      5
 75%      5
 80%      6
 90%      7
 95%     10
 98%     11
 99%     19
100%    131 (last request)

--- End Message ---
--- Begin Message ---
Eric Butera wrote:
On 7/11/06, Kevin Waterson <[EMAIL PROTECTED]> wrote:

How much of  a performance hit?

Kevin

--
"Democracy is two wolves and a lamb voting on what to have for lunch.
Liberty is a well-armed lamb contesting the vote."

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



Here's to being bored on lunch. :)


Now to add my two cents to the convo:
I don't see a problem with storing images in the DB IF they aren't
going to be continually accessed that way.  For example say you have a
script that lets a user upload an image and creates a small, medium,
and large view out of it.  Stick the original in the Db and then make
your 3 sizes on the fly and cache the output so they are not
continually created.  This way you could down the road re-do all the
sizes if you go through a site redesign or the client chooses they
want them 450 instead of 400. =)


Via MySQL 4.1 & PHP 5.1.4:
erics:~ eric$ ab -n500 -c5 http://localhost/fs_vs_db/viewimage_db.php
This is ApacheBench, Version 1.3d <$Revision: 1.73 $> apache-1.3
Copyright (c) 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ Copyright (c) 1998-2002 The Apache Software Foundation, http://www.apache.org/

Benchmarking localhost (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Finished 500 requests
Server Software:        Apache/1.3.33
Server Hostname:        localhost
Server Port:            80

Document Path:          /fs_vs_db/viewimage_db.php
Document Length:        25256 bytes

Concurrency Level:      5
Time taken for tests:   4.323 seconds
Complete requests:      500
Failed requests:        0
Broken pipe errors:     0
Total transferred:      12727000 bytes
HTML transferred:       12628000 bytes
Requests per second:    115.66 [#/sec] (mean)
Time per request:       43.23 [ms] (mean)
Time per request:       8.65 [ms] (mean, across all concurrent requests)
Transfer rate:          2944.02 [Kbytes/sec] received

Connnection Times (ms)
             min  mean[+/-sd] median   max
Connect:        0     0    0.4      0    10
Processing:    14    42   12.6     38   147
Waiting:       14    42   12.6     38   147
Total:         14    42   12.6     38   147

Percentage of the requests served within a certain time (ms)
 50%     38
 66%     40
 75%     44
 80%     46
 90%     56
 95%     67
 98%     78
 99%     97
100%    147 (last request)





Raw Image:
erics:~ eric$ ab -n500 -c5 http://localhost/fs_vs_db/cloud.jpg
This is ApacheBench, Version 1.3d <$Revision: 1.73 $> apache-1.3
Copyright (c) 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ Copyright (c) 1998-2002 The Apache Software Foundation, http://www.apache.org/

Benchmarking localhost (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Finished 500 requests
Server Software:        Apache/1.3.33
Server Hostname:        localhost
Server Port:            80

Document Path:          /fs_vs_db/cloud.jpg
Document Length:        25256 bytes

Concurrency Level:      5
Time taken for tests:   0.624 seconds
Complete requests:      500
Failed requests:        0
Broken pipe errors:     0
Total transferred:      12775000 bytes
HTML transferred:       12628000 bytes
Requests per second:    801.28 [#/sec] (mean)
Time per request:       6.24 [ms] (mean)
Time per request:       1.25 [ms] (mean, across all concurrent requests)
Transfer rate:          20472.76 [Kbytes/sec] received

Connnection Times (ms)
             min  mean[+/-sd] median   max
Connect:        0     1    0.7      1     5
Processing:     3     5    6.6      4   131
Waiting:        1     4    6.7      3   130
Total:          3     6    6.5      5   131

Percentage of the requests served within a certain time (ms)
 50%      5
 66%      5
 75%      5
 80%      6
 90%      7
 95%     10
 98%     11
 99%     19
100%    131 (last request)

The time taken per request, though (and that's about all we can get with a concurrency as low as 5) doesn't tell us much. We also don't know exactly what the PHP code is doing, how it does it, how your database is organized/indexed/accessed, if you have any PHP accelerators installed (Normally the PHP script would be reconverted to bytecode every execution), etc.

Additionally, your test isn't really MySQL versus filesystem, it's PHP+MySQL versus filesystem. Perhaps a more useful comparison would be PHP+Filesystem versus PHP+MySQL. As in, the same PHP script for both benchmarks, except one copy uses file_get_contents and echo (Closer match than readfile, since MySQL would require loading the file into memory) and the other uses MySQL. This would be a closer match that would tell us how much latency is induced by the actual database itself rather than PHP and loading stuff into memory.

Regards, Adam.

--- End Message ---
--- Begin Message ---
I have an array that i would like to sort and reorder based on a simple
critera.  I already order the data but I would like to break the data now
into sections by customer id, so one customer has 5 things and another
customer has one.  How can I do that with an array.

$data = orders($id,$status);
$c = count($data);
for($i=0; $i<$c; $i++) {
$orderid = $data[$i]['orderid'];
$customerid = $data[$i]['customerid'];
$name = $data[$i]['name'];
print $orderid.' - '.$customerid.' - '.$name.'<br>';
}

What it is currently is all the orders are ordered by the customer number,
however I would like to group it a little nicer on the output.

Current:
1234 - blah blah blah - Y - 3, 01234
1235 - blah blah blah - N - 6, 01234
1236 - blah blah blah - N - 6, 01234
1237 - blah blah blah - Y - 6, 11256
1238 - blah blah blah - N - 6, 22589
1239 - blah blah blah - N - 6, 22589
1240 - blah blah blah - Y - 6, 22589
1241 - blah blah blah - N - 6, 22589

Would like:
01234 - The Customer 1
1234 - blah blah blah - Y - 3
1235 - blah blah blah - N - 6
1236 - blah blah blah - N - 6

11256 - The Customer 2
1237 - blah blah blah - Y - 6

22589 - The Customer 3
1238 - blah blah blah - N - 6
1239 - blah blah blah - N - 6
1240 - blah blah blah - Y - 6
1241 - blah blah blah - N - 6

Anyway I can do that?

--- End Message ---
--- Begin Message ---
Ok I understand your method now. your code does not match your output. how
would your print line produce that , $customerid ?

anyways...

$data = orders($id,$status);
$c = count($data);
$currentId;
$n = 1;
for($i=0; $i<$c; $i++) {
   $orderid = $data[$i]['orderid'];
   $customerid = $data[$i]['customerid'];
   $name = $data[$i]['name'];
   if($currentid == $customerid) {
        //Continue current customer group
        print $orderid.' - '.$customerid.' - '.$name.'<br>';
   } else {
        //Begin a new group...
        $currentId = $customerid;
        Print("Customer ".$n");
        $n++;
   }
}

I'm kind of headed out so its a bit rushed and the example above wont work
as given but you get the idea from the two comments I added...
On 7/11/06, Dallas Cahker <[EMAIL PROTECTED]> wrote:

I have an array that i would like to sort and reorder based on a simple
critera.  I already order the data but I would like to break the data now
into sections by customer id, so one customer has 5 things and another
customer has one.  How can I do that with an array.

$data = orders($id,$status);
$c = count($data);

for($i=0; $i<$c; $i++) {
$orderid = $data[$i]['orderid'];
$customerid = $data[$i]['customerid'];
$name = $data[$i]['name'];
print $orderid.' - '.$customerid.' - '.$name.'<br>';
}

What it is currently is all the orders are ordered by the customer number,
however I would like to group it a little nicer on the output.

Current:
1234 - blah blah blah - Y - 3, 01234
1235 - blah blah blah - N - 6, 01234
1236 - blah blah blah - N - 6, 01234
1237 - blah blah blah - Y - 6, 11256
1238 - blah blah blah - N - 6, 22589
1239 - blah blah blah - N - 6, 22589
1240 - blah blah blah - Y - 6, 22589
1241 - blah blah blah - N - 6, 22589

Would like:
01234 - The Customer 1
1234 - blah blah blah - Y - 3
1235 - blah blah blah - N - 6
1236 - blah blah blah - N - 6

11256 - The Customer 2
1237 - blah blah blah - Y - 6

22589 - The Customer 3
1238 - blah blah blah - N - 6
1239 - blah blah blah - N - 6
1240 - blah blah blah - Y - 6
1241 - blah blah blah - N - 6

Anyway I can do that?



--- End Message ---
--- Begin Message ---
Dallas Cahker wrote:
> I have an array that i would like to sort and reorder based on a simple
> critera.  I already order the data but I would like to break the data now
> into sections by customer id, so one customer has 5 things and another
> customer has one.  How can I do that with an array.
> 
> $data = orders($id,$status);
> $c = count($data);
> for($i=0; $i<$c; $i++) {
> $orderid = $data[$i]['orderid'];
> $customerid = $data[$i]['customerid'];
> $name = $data[$i]['name'];
> print $orderid.' - '.$customerid.' - '.$name.'<br>';
> }

// something like this?:

$grouped = array();
foreach ($data as $d) {
        $cid = $d['customerid'];
        if (!isset($grouped[$cid])) {
                $grouped[$cid] = array(
                        'cust' => "{$cid} - {$d['name']}";
                        'data' => array();                      
                );
        }

        // I dont know exactly what constitutes an order line
        // - your example doesn't make it clear
        $grouped[$cid]['data'][] = "make a string of the current orderline 
here!";
}

foreach ($grouped as $cid => $data) {
        echo $data['cust'],"\n";
        foreach ($data['data'] as $orderline) echo $orderline,"\n";
}

> What it is currently is all the orders are ordered by the customer number,
> however I would like to group it a little nicer on the output.
> 

...

> 
> Anyway I can do that?

as many as there ways to skin a cat probably :-)

> 

--- End Message ---
--- Begin Message ---
Jochem Maas wrote:
> hi everyone,
> 
> I was wondering if anyone knew how (if possible) I could take a string
> and ftp_put()/ftp_fput() that string directly onto the remote server as a file
> (without first saving the string to disk temporarily locally)
> 
> I imagine that there is a way to create a stream that refers to the string
> in question but I can't get my head round the streams functionality...
> 
> Obviously saving the string temporarily to disk locally is an easy option
> but I was kind of using the situation I have now to try and do something a
> little fancy and learn something about streams.
> 
> anyone with idea/pointers?

I stumbled accross the following page while RTFMing:

        http://php.net/manual/en/wrappers.ftp.php

very nice, it enabled me the come up wth the following to lines (nice and 
compact!):

    $context = stream_context_create(array('ftp' => array('overwrite' => 
true)));
    $retval  = file_put_contents("ftp://{$ftp_user}:[EMAIL 
PROTECTED]:21/{$filename}", $xml, LOCK_EX, $context);

BUT this leaves me with the problem of determining what went wrong if the 
file_put_contents() call
fails. did the connection fail? did the login fail? did the write/upload fail 
(and why)?

using the std. ftp functions it's [obviously] alot easier to determine at which 
point the failure
occured. can anyone confirm I'm on the right track by trying to set 
'notification' [stream]context
parameter?

> 
> TIA,
> Jochem.
> 

--- End Message ---
--- Begin Message ---
I've noticed a 'feature' that seems to be causing me some pain.

When a user logs in, we store various pieces of info and their user class in
a $_SESSION variables.

This includes a flag saying that they've ben authenticated.

I would expect that if I 'rm -rf /tmp/sess_*' that the user would get
prompted to re-login (since the flag is not set).

However what actually happens, is that PHP silently just re-creates the
session with a new unique identifier but with all the same data in it. GRRR.

How can I force this to NOT happen (either via php.ini or via some function
or directive call in each page load)?

ÐÆ5ÏÐ 

--- End Message ---
--- Begin Message ---
Hi,
Something strange and dont really know what to expect
so was hoping you 
more experienced PHP 5 people can help me out.

We have been given a development server thats running
php5 with MySql 
Client API version 5.0.22 (didnt know there was one
that high)

the problem is, we have to develop on this and then
when its done the 
app will be moved to a php 4 final server...

I have been reading and i see that there are some php4
functions that 
act strange on php5 (like strpos)
are there any other things I should be aware of?

If you think it would be too much of a hassle, do you
think i should 
request the admin to install php 4 instead and scrap
this installation? 

I have also seen many sites having php4 and 5 on the
same machine, this 
is a windows server, is there any easy way to do that
here?

Thanks!
Ryan

------
- The faulty interface lies between the chair and the keyboard.
- Creativity is great, but plagiarism is faster!
- Smile, everyone loves a moron. :-)

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

--- End Message ---
--- Begin Message ---
It's silly to have two different environments like that.

Either code the thing in PHP4. or upgrade the production environment to
PHP5.

DÆVID  

> -----Original Message-----
> From: Ryan A [mailto:[EMAIL PROTECTED] 
> Sent: Tuesday, July 11, 2006 6:08 AM
> To: php php
> Subject: [PHP] PHP 5...
> 
> Hi,
> Something strange and dont really know what to expect
> so was hoping you 
> more experienced PHP 5 people can help me out.
> 
> We have been given a development server thats running
> php5 with MySql 
> Client API version 5.0.22 (didnt know there was one
> that high)
> 
> the problem is, we have to develop on this and then
> when its done the 
> app will be moved to a php 4 final server...
> 
> I have been reading and i see that there are some php4
> functions that 
> act strange on php5 (like strpos)
> are there any other things I should be aware of?
> 
> If you think it would be too much of a hassle, do you
> think i should 
> request the admin to install php 4 instead and scrap
> this installation? 
> 
> I have also seen many sites having php4 and 5 on the
> same machine, this 
> is a windows server, is there any easy way to do that
> here?
> 
> Thanks!
> Ryan
> 
> ------
> - The faulty interface lies between the chair and the keyboard.
> - Creativity is great, but plagiarism is faster!
> - Smile, everyone loves a moron. :-)
> 
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around 
> http://mail.yahoo.com 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 

--- End Message ---
--- Begin Message ---
Unless there is some specific reason that you need this code to run on both
php4 and php5, then inform your boss/admin that the idea of developing on
php5, to deploy on php4 is nuts. If they disagree inform them that they are
personally nuts( tell them some guy on the internet said so ).

It may be possible to develop php5 code in a php5 env, if you are intimately
familiar with the differences between php4 and php5, but if you're that
familiar with PHP, then you're worth more than a half-ass software creation
enviornment.

Basicly it's a catch22 if you're good enough to be able to cope with this
enviornment, you shouldn't have to.




--- End Message ---
--- Begin Message ---
Hello all,

This is the first time I have posted an issue to this forum, so please
excuse in noob questions or statement. I am trying to create a table
from a string that created by a DESCRIBE TABLE query... this is the
generated string:

CREATE TABLE 'users' ( 'username' varchar(120) NOT NULL primary key,
'password' varchar(64) NOT NULL, 'level' int(11) NOT NULL DEFAULT '0'
)

then I use the statement:

$db is a PEAR DB object that has been set up with my database access
info and connects to MYSQL.
$stmt = above create string.

$db->query ( $stmt );

for some reason it is not creating the desired table. Can anyone give
me a solution or a reason why the above situation would not work. Just
to clarify that my Database info is correct I was able to generate the
create string from a DESCRIBE TABLE query so the connection works and
is valid and I have CREATE rights.

--- End Message ---
--- Begin Message ---
At 5:05 PM -0700 7/11/06, Scott Heinrichs wrote:
>Can anyone give me a solution

If all else fails, use phpAdminMySQL to set up your tables. I seldom program it.

tedd
-- 
------------------------------------------------------------------------------------
http://sperling.com  http://ancientstones.com  http://earthstones.com

--- End Message ---

Reply via email to