Re: [PHP] performance issues

2008-04-17 Thread Robert Cummings

On Wed, 2008-04-16 at 23:37 -0400, Nathan Nobbe wrote:
 all,
 
 i have heard from various sources that using the  in php can at times be
 costly, and therefore, it should not be used when it is not needed.  for
 example, passing an array by reference because you think youre passing the
 actual array is not a good idea.  only pass it by reference if a modified
 version needs to be handed to the calling code via an actual parameter.
 im also wondering about php4 code thats now running under 5; such as
 function returnObject() ...
 $a = new SomeClass() ...
 lets suppose, for the sake of arguments, i have my hands on a codebase where
 everything actually does count.  the code was php4 and is now transitioning
 to 5.  does anybody know if there would be a performance gain in running the
 whole thing through sed to try and strip out the unnecessary  characters ?
 any empirical data?

If it's faster, it's faster so that would suggest a performance gain...
but as many will tell you, and you most likely already know... is the
gain worth the effort? BTW, rote replacement of references like that,
may not be a good idea. There are times when you really do want a
reference to an object... or maybe not... but you or someone else might
have done it anyways ;)

Contrast:
?php

$b = new Foo();
$a = $b;
$a = new Fee();

?

Versus:
?php

$b = new Foo();
$a = $b;
$a new Fee();

?

In the first $b references the instance of Fee since $a is a reference.
In the second, $b remains an instance of Foo when $a becomes and
instance of Fee.

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


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



Re: [PHP] Database abstraction?

2008-04-17 Thread Chris

Jason Pruim wrote:


On Apr 16, 2008, at 5:37 PM, Chris wrote:


Jason Pruim wrote:

Hi Everyone!
I'm back with yet another question But getting closer to sounding 
like I know what I'm talking about and that's all thanks to all of 
you. A free beer (Or beverage of choice)* for everyone who has helped 
me over the years!
Here's my question... I have a program, where I want to take out the 
field names in a database table and display them... In other words 
instead of writing:

$Query =SELECT First, Last, Middle, Add1 FROM mytable order by $order;
I want to write something more like:
$Query =SELECT $FIELDNAMES FROM mytable order by $order;
So I need to know how to get the field names from the database so 
that I can populate $FIELDNAMES. I played a little bit and it looks 
like I might be able to get what I want by doing 2 queries...

$QueryFieldNames = DESCRIBE $table;
And then some sort of a foreach or maybe a while to populate 
$FIELDNAMES? Maybe an array so I could do $FIELDNAMES['First'] if I 
needed to later.
then I can use my SELECT $FIELDNAMES FROM $table order by $order 
query to do my query...


If $FIELDNAMES contains all the fields, I have to ask why?


What I am trying to accomplish is a customer wants me to add custom 
fields to their table in my database, I want to use the same code to 
display the separate fields... In other words right now I have the field 
names hard coded into my app.. I want to be able to remove the actual 
field names and have them pulled dynamically from the database, so it 
doesn't matter if there is 10 fields or 30 fields, it will print a 
header row that contains ALL the field names and format the table properly.


Sure - but you can do it all in one go.

Another approach (which is database independent) is

select * from table limit 0;


Had to throw that in the mix :)

--
Postgresql  php tutorials
http://www.designmagick.com/

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



Re: [PHP] PHP with NNTP?

2008-04-17 Thread Per Jessen
vester_s wrote:

 I need to get the list for all of the people that subscribing to this
 newsreader, this list will be used to modify the other mailing list
 programs.
 
 Basically by getting the list of the people that subscribing on this
 newsgroup, then i could migrate it to our new forum based.
 
 So is it possible for getting those list?

You can always check the news-server logfiles.  I think that's probably
the best place to get some user/usage information.  


/Per Jessen, Zürich


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



[PHP] FRench characters not displayed correctly

2008-04-17 Thread Angelo Zanetti
Hi all.

We have taken over a site and a problem we have is that French special
characters aren't displaying correctly, they are displaying a weird square
block.

I have checked the content type and it's as follows: 

meta http-equiv=Content-Type content=text/html;charset=utf-8 

I also notice that the charset=iso-8859-1 is missing in the above meta
tag, could this be affecting the characters?

I have seen that there is no DOCTYPE declaration, could this be the problem
if this is omitted?

If you have any suggestions, please let me know.

TIA.

Angelo

Web: http://www.elemental.co.za 



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



Re: [PHP] PHP with NNTP?

2008-04-17 Thread Stut

On 16 Apr 2008, at 23:50, vester_s wrote:

I need to get the list for all of the people that subscribing to this
newsreader, this list will be used to modify the other mailing list
programs.

Basically by getting the list of the people that subscribing on this
newsgroup, then i could migrate it to our new forum based.

So is it possible for getting those list?


Really not sure what you mean by modify the other mailing list  
programs.


And nobody subscribed to this mailing list has agreed to have an  
account on your new forum.


So no, I won't help you get their details.

Have a cracking day.

-Stut

--
http://stut.net/


Stut wrote:


On 16 Apr 2008, at 18:01, vester_s wrote:

Is it possible to do it without using imap? I am trying to get the
list of
all users that is on the newsgroup, is that possible?


I'm wondering what possible legitimate reason you could have for
wanting that list?

There is a way to get it (it's not easy but it's possible) but  
until I

know why you want it I'm not sharing.

-Stut

--
http://stut.net/


chris smith-9 wrote:


vester_s wrote:

Hi,

Can anybody tell me how can php connect to NNTP to get the list of
all
users
in the newsgroups?


http://php.net/imap supports nntp.

--
Postgresql  php tutorials
http://www.designmagick.com/

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





--
View this message in context:
http://www.nabble.com/PHP-with-NNTP--tp16713817p16723692.html
Sent from the PHP - General mailing list archive at Nabble.com.


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




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





--
View this message in context: 
http://www.nabble.com/PHP-with-NNTP--tp16713817p16735336.html
Sent from the PHP - General mailing list archive at Nabble.com.


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




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



RE: [PHP] FRench characters not displayed correctly

2008-04-17 Thread Angelo Zanetti


-Original Message-
From: Angelo Zanetti [mailto:[EMAIL PROTECTED] 
Sent: 17 April 2008 09:48
To: php-general@lists.php.net
Subject: [PHP] FRench characters not displayed correctly 

Hi all.

We have taken over a site and a problem we have is that French special
characters aren't displaying correctly, they are displaying a weird square
block.

I have checked the content type and it's as follows: 

meta http-equiv=Content-Type content=text/html;charset=utf-8 

I also notice that the charset=iso-8859-1 is missing in the above meta
tag, could this be affecting the characters?

I have seen that there is no DOCTYPE declaration, could this be the problem
if this is omitted?

If you have any suggestions, please let me know.

TIA.

Angelo

Web: http://www.elemental.co.za 




I have also found that we can do this: 

html lang=fr

But I am interested in finding out if the doctype declaration is a
contributing factor.

Thanks
Angelo





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



[PHP] PHP5 and the DOM model

2008-04-17 Thread Michael Preminger

Hello!

Seems that PHP gets more and more object oriented, which is good.

I am now running a course in PHP, using PHP 5, where we are going to
use the *DOM* interface. I am trying to teach them good OO practices,
meaning that we insistently hide properties and expose them as get or
set methods.

Looking at the PHPs *DOM* implementation, I see that many of the
properties are exposed directly, without even offering get methods.

1. Is there something I am misunderstanding orotherwise missing? (I
havenot used *DOM* in PHP before).

2.This poses a pedagogical problem for me as a teacher. How do I
explain this contradiction to my students?

Thanks

Michael

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



Re: [PHP] FRench characters not displayed correctly

2008-04-17 Thread Robert Cummings

On Thu, 2008-04-17 at 09:47 +0200, Angelo Zanetti wrote:
 Hi all.
 
 We have taken over a site and a problem we have is that French special
 characters aren't displaying correctly, they are displaying a weird square
 block.
 
 I have checked the content type and it's as follows: 
 
 meta http-equiv=Content-Type content=text/html;charset=utf-8 
 
 I also notice that the charset=iso-8859-1 is missing in the above meta
 tag, could this be affecting the characters?

You certainly wouldn't want both utf-8 and iso-8859-1 declared at the
same time. It sounds like what you want is iso-8859-1 and NOT utf-8.
Check the encoding of either your files or your database content. Also
check what headers PHP is sending to the browser. If you're using
Firefox you can check the page info to see what charset it thinks it
received.

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


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



RE: [PHP] French characters not displayed correctly

2008-04-17 Thread Per Jessen
Angelo Zanetti wrote:

 I have also found that we can do this:
 
 html lang=fr
 
 But I am interested in finding out if the doctype declaration is a
 contributing factor.

Neither will affect the character set used when rendering the page. 

The meta http-equiv=Content-Type in a page is ignored by the browser
if an http header with a Content-Type has already been sent.  If you
bring up the page in Firefox, and hit Ctrl-I, I'll bet it says the page
is being displayed in ISO-8859-1 (well, not UTF8 at least).

I would check the default_charset setting in php.ini. 


/Per Jessen, Zürich


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



RE: [PHP] FRench characters not displayed correctly

2008-04-17 Thread Angelo Zanetti


-Original Message-
From: Robert Cummings [mailto:[EMAIL PROTECTED] 
Sent: 17 April 2008 10:38
To: Angelo Zanetti
Cc: php-general@lists.php.net
Subject: Re: [PHP] FRench characters not displayed correctly


On Thu, 2008-04-17 at 09:47 +0200, Angelo Zanetti wrote:
 Hi all.
 
 We have taken over a site and a problem we have is that French special
 characters aren't displaying correctly, they are displaying a weird square
 block.
 
 I have checked the content type and it's as follows: 
 
 meta http-equiv=Content-Type content=text/html;charset=utf-8 
 
 I also notice that the charset=iso-8859-1 is missing in the above meta
 tag, could this be affecting the characters?

You certainly wouldn't want both utf-8 and iso-8859-1 declared at the
same time. It sounds like what you want is iso-8859-1 and NOT utf-8.
Check the encoding of either your files or your database content. Also
check what headers PHP is sending to the browser. If you're using
Firefox you can check the page info to see what charset it thinks it
received.

Cheers,
Rob.
-- 


Thanks Robert, 

I have the following headers:


http://fr..com/student/themes/english/locker_room/student.html

GET /student/themes/english/locker_room/student.html? HTTP/1.1
Host: fr..com
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.14)
Gecko/20080404 Firefox/2.0.0.14
Accept:
text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=
0.8,image/png,*/*;q=0.5
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Referer: http://fr..com/student/themes/english/locker_room/student.html
Cookie: PHPSESSID=818678404c170c8e4f5d237c1d0280a8
If-Modified-Since: Sat, 17 Nov 2007 11:40:26 GMT
If-None-Match: 6b97e-a9d-619b9e80
Cache-Control: max-age=0

HTTP/1.x 304 Not Modified
Date: Thu, 17 Apr 2008 08:31:32 GMT
Server: Apache/2.0.55 (Unix) PHP/5.1.2
Connection: Keep-Alive
Keep-Alive: timeout=15, max=200
Etag: 6b97e-a9d-619b9e80
-


Now I see that the headers have: 

Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7

Which to me seems like it is sending both ISO-8859-1 and UTF-8? 

What else should I be checking for? 

Could it be a PHP problem where PHP isn't decoding the characters properly?

Thanks again.


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



RE: [PHP] FRench characters not displayed correctly

2008-04-17 Thread Robert Cummings

On Thu, 2008-04-17 at 10:57 +0200, Angelo Zanetti wrote:

 Thanks Robert, 
 
 I have the following headers:
 
 
 http://fr..com/student/themes/english/locker_room/student.html
 
 GET /student/themes/english/locker_room/student.html? HTTP/1.1
 Host: fr..com
 User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.14)
 Gecko/20080404 Firefox/2.0.0.14
 Accept:
 text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=
 0.8,image/png,*/*;q=0.5
 Accept-Language: en-us,en;q=0.5
 Accept-Encoding: gzip,deflate
 Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
 Keep-Alive: 300
 Connection: keep-alive
 Referer: http://fr..com/student/themes/english/locker_room/student.html
 Cookie: PHPSESSID=818678404c170c8e4f5d237c1d0280a8
 If-Modified-Since: Sat, 17 Nov 2007 11:40:26 GMT
 If-None-Match: 6b97e-a9d-619b9e80
 Cache-Control: max-age=0
 
 HTTP/1.x 304 Not Modified
 Date: Thu, 17 Apr 2008 08:31:32 GMT
 Server: Apache/2.0.55 (Unix) PHP/5.1.2
 Connection: Keep-Alive
 Keep-Alive: timeout=15, max=200
 Etag: 6b97e-a9d-619b9e80
 -
 
 
 Now I see that the headers have: 
 
 Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
 
 Which to me seems like it is sending both ISO-8859-1 and UTF-8? 

No, that's what kind of content the server is willing to accept from
various sources such as POST.  You want the following somewhere near the
beginning of your script:

?php

header( 'Content-type: text/html; charset=iso-8859-1' );

?

Cheers,
Rob.

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


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



RE: [PHP] FRench characters not displayed correctly

2008-04-17 Thread Angelo Zanetti


-Original Message-
From: Robert Cummings [mailto:[EMAIL PROTECTED] 
Sent: 17 April 2008 11:05
To: Angelo Zanetti
Cc: php-general@lists.php.net
Subject: RE: [PHP] FRench characters not displayed correctly


On Thu, 2008-04-17 at 10:57 +0200, Angelo Zanetti wrote:

 Thanks Robert, 
 
 I have the following headers:
 
 
 http://fr..com/student/themes/english/locker_room/student.html
 
 GET /student/themes/english/locker_room/student.html? HTTP/1.1
 Host: fr..com
 User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.14)
 Gecko/20080404 Firefox/2.0.0.14
 Accept:

text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=
 0.8,image/png,*/*;q=0.5
 Accept-Language: en-us,en;q=0.5
 Accept-Encoding: gzip,deflate
 Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
 Keep-Alive: 300
 Connection: keep-alive
 Referer:
http://fr..com/student/themes/english/locker_room/student.html
 Cookie: PHPSESSID=818678404c170c8e4f5d237c1d0280a8
 If-Modified-Since: Sat, 17 Nov 2007 11:40:26 GMT
 If-None-Match: 6b97e-a9d-619b9e80
 Cache-Control: max-age=0
 
 HTTP/1.x 304 Not Modified
 Date: Thu, 17 Apr 2008 08:31:32 GMT
 Server: Apache/2.0.55 (Unix) PHP/5.1.2
 Connection: Keep-Alive
 Keep-Alive: timeout=15, max=200
 Etag: 6b97e-a9d-619b9e80
 -
 
 
 Now I see that the headers have: 
 
 Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
 
 Which to me seems like it is sending both ISO-8859-1 and UTF-8? 

No, that's what kind of content the server is willing to accept from
various sources such as POST.  You want the following somewhere near the
beginning of your script:

?php

header( 'Content-type: text/html; charset=iso-8859-1' );

?

Cheers,
Rob.
-

Thanks again, but as far as I have read, it seems that UTF-8 has better
handling for French characters?

We have the following in our HTML page: 

meta http-equiv=Content-Type content=text/html;charset=utf-8 


Would the header not conflict with this meta tag?

Angelo


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



Re: [PHP] DateTime... What else ?

2008-04-17 Thread Stut

On 17 Apr 2008, at 10:05, David BERCOT wrote:

I've got a problem with DateTime. I have a short code which gives an
error :

CODE
$date = new DateTime(date(d/m/Y));
$date-modify(-1 month);
$mois_en_cours1 = $date-format(Y-m);
$date-modify(-1 month);
$mois_en_cours2 = $date-format(Y-m);
$date-modify(-1 month);
$mois_en_cours3 = $date-format(Y-m);
/CODE

ERROR
bFatal error/b:  Class 'DateTime' not found in
b/var/www2/dacg_visio/index.html/b on line b244/bbr /
/ERROR

If I look at the documentation :
http://fr3.php.net/manual/fr/function.date-modify.php
it seems to work if PHP version is above 5.1.0 (I am in 5.1.6 !).

Do you have any idea about this error (Debian/Apache2) ?
Do you have another way to obtain $mois_en_cours1, 2, 3 without
DateTime ?


Pre-5.2 you need to explicitly say you want the DateTime class. See  
the note on this page: http://fr3.php.net/manual/fr/datetime.installation.php


Also note that it's experimental at the moment and therefore not  
recommended for production usage.


-Stut

--
http://stut.net/

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



RE: [PHP] FRench characters not displayed correctly

2008-04-17 Thread Robert Cummings

On Thu, 2008-04-17 at 11:11 +0200, Angelo Zanetti wrote:
 
 -Original Message-
 From: Robert Cummings [mailto:[EMAIL PROTECTED] 
 Sent: 17 April 2008 11:05
 To: Angelo Zanetti
 Cc: php-general@lists.php.net
 Subject: RE: [PHP] FRench characters not displayed correctly
 
 
 On Thu, 2008-04-17 at 10:57 +0200, Angelo Zanetti wrote:
 
  Thanks Robert, 
  
  I have the following headers:
  
  
  http://fr..com/student/themes/english/locker_room/student.html
  
  GET /student/themes/english/locker_room/student.html? HTTP/1.1
  Host: fr..com
  User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.14)
  Gecko/20080404 Firefox/2.0.0.14
  Accept:
 
 text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=
  0.8,image/png,*/*;q=0.5
  Accept-Language: en-us,en;q=0.5
  Accept-Encoding: gzip,deflate
  Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
  Keep-Alive: 300
  Connection: keep-alive
  Referer:
 http://fr..com/student/themes/english/locker_room/student.html
  Cookie: PHPSESSID=818678404c170c8e4f5d237c1d0280a8
  If-Modified-Since: Sat, 17 Nov 2007 11:40:26 GMT
  If-None-Match: 6b97e-a9d-619b9e80
  Cache-Control: max-age=0
  
  HTTP/1.x 304 Not Modified
  Date: Thu, 17 Apr 2008 08:31:32 GMT
  Server: Apache/2.0.55 (Unix) PHP/5.1.2
  Connection: Keep-Alive
  Keep-Alive: timeout=15, max=200
  Etag: 6b97e-a9d-619b9e80
  -
  
  
  Now I see that the headers have: 
  
  Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
  
  Which to me seems like it is sending both ISO-8859-1 and UTF-8? 
 
 No, that's what kind of content the server is willing to accept from
 various sources such as POST.  You want the following somewhere near the
 beginning of your script:
 
 ?php
 
 header( 'Content-type: text/html; charset=iso-8859-1' );
 
 ?
 
 Cheers,
 Rob.
 -
 
 Thanks again, but as far as I have read, it seems that UTF-8 has better
 handling for French characters?
 
 We have the following in our HTML page: 
 
 meta http-equiv=Content-Type content=text/html;charset=utf-8 
 
 
 Would the header not conflict with this meta tag?

You can't just change the header or meta tags and expect things to work.
The header must match the type of content you have. The point of th
eheader is to tell the browser what all those multi-byte sequences mean.
If you want to change to UTF-8 and your data is in ISO-8859-1 then you
need to convert the content from one type to the other (I usually use
iconv on the command-line). Until you do so, you should set your header
to whatever content type you have... I'm guessing ISO-8859-1 but maybe
you have UTF-8.

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


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



Re: [PHP] DateTime... What else ?

2008-04-17 Thread Simon Welsh


On 17/04/2008, at 9:05, David BERCOT wrote:

Hi,

I've got a problem with DateTime. I have a short code which gives an
error :

CODE
$date = new DateTime(date(d/m/Y));
$date-modify(-1 month);
$mois_en_cours1 = $date-format(Y-m);
$date-modify(-1 month);
$mois_en_cours2 = $date-format(Y-m);
$date-modify(-1 month);
$mois_en_cours3 = $date-format(Y-m);
/CODE

ERROR
bFatal error/b:  Class 'DateTime' not found in
b/var/www2/dacg_visio/index.html/b on line b244/bbr /
/ERROR

If I look at the documentation :
http://fr3.php.net/manual/fr/function.date-modify.php
it seems to work if PHP version is above 5.1.0 (I am in 5.1.6 !).

Do you have any idea about this error (Debian/Apache2) ?
Do you have another way to obtain $mois_en_cours1, 2, 3 without
DateTime ?

Thank you very much.

David.


--  
PHP General Mailing List (http://www.php.net/)

To unsubscribe, visit: http://www.php.net/unsub.php




?php
$mois_en_cours1 = date('Y-m', strtotime('-1 month'));
$mois_en_cours2 = date('Y-m', strtotime('-2 month'));
$mois_en_cours3 = date('Y-m', strtotime('-3 month'));
?

---
Simon Welsh
Admin of http://simon.geek.nz/

Windows is a joke operating system. Hell, it's not even an operating  
system. NT is Not Tough enough for me either. 95 is how may times it  
will crash an hour.


http://www.thinkgeek.com/brain/gimme.cgi?wid=81d520e5e



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



[PHP] DateTime... What else ?

2008-04-17 Thread David BERCOT
Hi,

I've got a problem with DateTime. I have a short code which gives an
error :

CODE
$date = new DateTime(date(d/m/Y));
$date-modify(-1 month);
$mois_en_cours1 = $date-format(Y-m);
$date-modify(-1 month);
$mois_en_cours2 = $date-format(Y-m);
$date-modify(-1 month);
$mois_en_cours3 = $date-format(Y-m);
/CODE

ERROR
bFatal error/b:  Class 'DateTime' not found in
b/var/www2/dacg_visio/index.html/b on line b244/bbr /
/ERROR

If I look at the documentation :
http://fr3.php.net/manual/fr/function.date-modify.php
it seems to work if PHP version is above 5.1.0 (I am in 5.1.6 !).

Do you have any idea about this error (Debian/Apache2) ?
Do you have another way to obtain $mois_en_cours1, 2, 3 without
DateTime ?

Thank you very much.

David.


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



RE: [PHP] FRench characters not displayed correctly

2008-04-17 Thread Per Jessen
Angelo Zanetti wrote:

 Thanks again, but as far as I have read, it seems that UTF-8 has
 better handling for French characters?

Not really - I'm pretty certain ISO-8859-1 will cover all of the special
french characters.  But it's irrelevant - if your code/pages are
written in UTF8, you won't get the desired result if you serve them as
ISO-8859-1. 

 We have the following in our HTML page:
 
 meta http-equiv=Content-Type content=text/html;charset=utf-8 
 
 Would the header not conflict with this meta tag?

No, your header didn't have a Content-Type listed, so I think your
meta-tag should work. 


/Per Jessen, Zürich


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



RE: [PHP] FRench characters not displayed correctly

2008-04-17 Thread Per Jessen
Robert Cummings wrote:

 No, that's what kind of content the server is willing to accept from
 various sources such as POST.  You want the following somewhere near
 the beginning of your script:
 
 ?php
 header( 'Content-type: text/html; charset=iso-8859-1' );
 ?

I think that is better done with the default_charset setting in php.ini. 


/Per Jessen, Zürich


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



Re: [PHP] What is the practical use of abstract and interface?

2008-04-17 Thread Robin Vickery
On 16/04/2008, Tony Marston [EMAIL PROTECTED] wrote:


   -Original Message-
   From: Robin Vickery [mailto:[EMAIL PROTECTED]
   Sent: 16 April 2008 17:23
   To: Jay Blanchard
   Cc: Tony Marston; php-general@lists.php.net
   Subject: Re: [PHP] What is the practical use of abstract
   and interface?
  
  
   On 16/04/2008, Jay Blanchard [EMAIL PROTECTED] wrote:
[snip]
  What about encapsulation?
   
 Interfaces have nothing to do with encapsulation for the
   smple reason
that I  can have encapsulation without using interfaces.
  
   Unique use of logic there.
  
   By similar reasoning; swimming trunks have nothing to do with
   swimming for the simple reason that I can swim without trunks.


 Correct. Encapsulation and polymorphism can be achieved without interfaces,
  therefore interfaces are not necessary.

You've switched positions from have nothing to do with to not
necessary. Prefacing your statement with Correct makes it appear
that you're merely re-affirming your original position.

  There is nothing I can achieve with interfaces that I cannot achieve without
  them, therefore they are not necessary. Not only are they not necessary,
  because they do not add value they are totally useless.

There's nothing that you can achieve with PHP5 that you can't achieve
with PHP/FI either. Maybe it's time to scrap all this needless
complexity and return to our roots.

I've already given an example of how formally defined interfaces add
value and you chose to dismiss it on the grounds that there's no need
to check interfaces if you don't use interfaces. *Every* modular
system uses interfaces whether they're formally defined or not.

  Some people seem to use them simply because they are there, or that
  was how they were taught.

Some people don't use them because they weren't there when they
learnt, or they weren't taught how. What's your point?

You are still missing the fundamental point. There is absolutely
nothing I can do WITH interfaces that I cannot do WITHOUT them,
therefore they are redundant.
  
   How about compile-time checking that the interface has been
   correctly implemented?


 If you don't use interfaces there is no need for such checking.

ok, s/interface/api/ if that makes you happier.

If you need a concrete example, lets say your app has a nifty
plugin system so third-parties can extend it. You have an API for
plugins to register themselves, and each plugin exposes a set of
methods that your application calls when necessary.

If you define an 'interface' for your API and each plugin implements
that interface, then if there's a plugin that doesn't implement it
properly you'll know as soon as the plugin loads.

If you don't formally define the interface, you're not going to know
that the plugin's wrong until the badly implemented method gets
called. And even then it might just introduce a hard to diagnose bug
rather than an obvious failure.

-robin

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



RE: [PHP] FRench characters not displayed correctly

2008-04-17 Thread Robert Cummings

On Thu, 2008-04-17 at 11:39 +0200, Per Jessen wrote:
 Robert Cummings wrote:
 
  No, that's what kind of content the server is willing to accept from
  various sources such as POST.  You want the following somewhere near
  the beginning of your script:
  
  ?php
  header( 'Content-type: text/html; charset=iso-8859-1' );
  ?
 
 I think that is better done with the default_charset setting in php.ini.

I don't. But then I have several projects and some use utf-8 (preferred)
and some use iso-8859-1 (not preferred). I prefer it in the virtual host
config personally :)

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


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



RE: [PHP] FRench characters not displayed correctly

2008-04-17 Thread Per Jessen
Robert Cummings wrote:

  
  ?php
  header( 'Content-type: text/html; charset=iso-8859-1' );
  ?
 
 I think that is better done with the default_charset setting in
 php.ini.
 
 I don't. But then I have several projects and some use utf-8
 (preferred) and some use iso-8859-1 (not preferred). I prefer it in
 the virtual host config personally :)

Ah yes, that's what I meant of course.  (I actually do everything in
UTF8 anyway).



/Per Jessen, Zürich


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



Re: [PHP] performance issues

2008-04-17 Thread Bojan Tesanovic


On Apr 17, 2008, at 5:37 AM, Nathan Nobbe wrote:


all,

i have heard from various sources that using the  in php can at  
times be
costly, and therefore, it should not be used when it is not  
needed.  for
example, passing an array by reference because you think youre  
passing the
actual array is not a good idea.  only pass it by reference if a  
modified
version needs to be handed to the calling code via an actual  
parameter.

im also wondering about php4 code thats now running under 5; such as
function returnObject() ...
$a = new SomeClass() ...
lets suppose, for the sake of arguments, i have my hands on a  
codebase where
everything actually does count.  the code was php4 and is now  
transitioning
to 5.  does anybody know if there would be a performance gain in  
running the
whole thing through sed to try and strip out the unnecessary   
characters ?

any empirical data?

thx,

-nathan




in PHP5 by default Objects are passed by reference and as you can see  
at this graph passing array by reference in PHP5 is slower

http://nathan.moxune.com/arrayVsArrayIteratorReport.php



Bojan Tesanovic
http://www.carster.us/






Re: [PHP] DateTime... What else ?

2008-04-17 Thread David BERCOT
Hi again,

Le Thu, 17 Apr 2008 21:10:44 +1200,
Simon Welsh [EMAIL PROTECTED] a écrit :
 On 17/04/2008, at 9:05, David BERCOT wrote:
  Hi,
 
  I've got a problem with DateTime. I have a short code which gives an
  error :
 
  CODE
  $date = new DateTime(date(d/m/Y));
  $date-modify(-1 month);
  $mois_en_cours1 = $date-format(Y-m);
  $date-modify(-1 month);
  $mois_en_cours2 = $date-format(Y-m);
  $date-modify(-1 month);
  $mois_en_cours3 = $date-format(Y-m);
  /CODE
 
  ERROR
  bFatal error/b:  Class 'DateTime' not found in
  b/var/www2/dacg_visio/index.html/b on line b244/bbr /
  /ERROR
 
  If I look at the documentation :
  http://fr3.php.net/manual/fr/function.date-modify.php
  it seems to work if PHP version is above 5.1.0 (I am in 5.1.6 !).
 
  Do you have any idea about this error (Debian/Apache2) ?
  Do you have another way to obtain $mois_en_cours1, 2, 3 without
  DateTime ?
 
  Thank you very much.
 
  David.
 
 ?php
 $mois_en_cours1 = date('Y-m', strtotime('-1 month'));
 $mois_en_cours2 = date('Y-m', strtotime('-2 month'));
 $mois_en_cours3 = date('Y-m', strtotime('-3 month'));
 ?

Great ;-)

Thank you very much !

David.


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



Re: [PHP] DateTime... What else ?

2008-04-17 Thread David BERCOT
Le Thu, 17 Apr 2008 10:19:10 +0100,
Stut [EMAIL PROTECTED] a écrit :
 On 17 Apr 2008, at 10:05, David BERCOT wrote:
  I've got a problem with DateTime. I have a short code which gives an
  error :
 
  CODE
  $date = new DateTime(date(d/m/Y));
  $date-modify(-1 month);
  $mois_en_cours1 = $date-format(Y-m);
  $date-modify(-1 month);
  $mois_en_cours2 = $date-format(Y-m);
  $date-modify(-1 month);
  $mois_en_cours3 = $date-format(Y-m);
  /CODE
 
  ERROR
  bFatal error/b:  Class 'DateTime' not found in
  b/var/www2/dacg_visio/index.html/b on line b244/bbr /
  /ERROR
 
  If I look at the documentation :
  http://fr3.php.net/manual/fr/function.date-modify.php
  it seems to work if PHP version is above 5.1.0 (I am in 5.1.6 !).
 
  Do you have any idea about this error (Debian/Apache2) ?
  Do you have another way to obtain $mois_en_cours1, 2, 3 without
  DateTime ?
 
 Pre-5.2 you need to explicitly say you want the DateTime class. See  
 the note on this page:
 http://fr3.php.net/manual/fr/datetime.installation.php
 
 Also note that it's experimental at the moment and therefore not  
 recommended for production usage.

OK. So, my error is normal !!!

Thank you very much.

David.


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



Re: [PHP] Hack question

2008-04-17 Thread Al
Can you explain this in more detail for me. Sounds like this code is providing the entry point for 
the other hack code.




Greg Bowser wrote:

 I can sort of figure what is doing; but, I can't figure out what the hacker
is using it for.


It will allow him to upload and execute arbitrary code on your server.
 Generally speaking, arbitrary code execution is a bad thing. :).


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



Re: [PHP] Database abstraction?

2008-04-17 Thread Jason Pruim


On Apr 17, 2008, at 2:16 AM, Chris wrote:

Jason Pruim wrote:

On Apr 16, 2008, at 5:37 PM, Chris wrote:

Jason Pruim wrote:

Hi Everyone!
I'm back with yet another question But getting closer to  
sounding like I know what I'm talking about and that's all thanks  
to all of you. A free beer (Or beverage of choice)* for everyone  
who has helped me over the years!
Here's my question... I have a program, where I want to take out  
the field names in a database table and display them... In other  
words instead of writing:
$Query =SELECT First, Last, Middle, Add1 FROM mytable order by  
$order;

I want to write something more like:
$Query =SELECT $FIELDNAMES FROM mytable order by $order;
So I need to know how to get the field names from the database so  
that I can populate $FIELDNAMES. I played a little bit and it  
looks like I might be able to get what I want by doing 2 queries...

$QueryFieldNames = DESCRIBE $table;
And then some sort of a foreach or maybe a while to populate  
$FIELDNAMES? Maybe an array so I could do $FIELDNAMES['First'] if  
I needed to later.
then I can use my SELECT $FIELDNAMES FROM $table order by $order  
query to do my query...


If $FIELDNAMES contains all the fields, I have to ask why?
What I am trying to accomplish is a customer wants me to add custom  
fields to their table in my database, I want to use the same code  
to display the separate fields... In other words right now I have  
the field names hard coded into my app.. I want to be able to  
remove the actual field names and have them pulled dynamically from  
the database, so it doesn't matter if there is 10 fields or 30  
fields, it will print a header row that contains ALL the field  
names and format the table properly.


Sure - but you can do it all in one go.

Another approach (which is database independent) is

select * from table limit 0;


Had to throw that in the mix :)


Maybe I'm showing my ignorance here in programming... Maybe it's  
because I delt with a kid who decided to scream for a good share of  
the night and I'm sleep deprived :) But in my current system I have  
this:


echo HTML

div
table border=1
tr
tda href=?order=aFirst Name/a/td
tda href=?order=bLast Name/a/td
tda href=?order=cAddress 1/a/td
tda href=?order=dAddress 2/a/td
tda href=?order=eCity/a/td
tda href=?order=fState/a/td
tda href=?order=gZip/a/td
tda href=?order=hCode/a/td
tda href=?order=iID #/a/td
HTML;

while($row = mysqli_fetch_assoc($result)) {
//display the info using heredoc syntac
echo HTML
tr
td{$row['FName']}/td
td{$row['LName']}/td
td{$row['Add1']}/td
td{$row['Add2']}/td
td{$row['City']}/td
td{$row['State']}/td
td{$row['Zip']}/td
td{$row['XCode']}/td
td{$row['Record']}/td
HTML;
}

What I want to do is take that first block of code, the one with the  
links for sorting, and instead of this: tda href=?order=aFirst  
Name/a/td I want to put something more like this: tda href=? 
order=a$FIELDNAMES[$field{$id}]/a/td So I can grab the field  
names from the database, instead of hardcoding them into my program.


I think I am sleep deprived because the more I tried to clarify it...  
the harder it got for me to understand :)


I need caffeine... Maybe a trip out to the gas station is in order  
before I attempt to write more code


?PHP while($baby !=sleep){$caffeine = $critical}?
or something like that :)



--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424-9337
www.raoset.com
[EMAIL PROTECTED]




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



Re: [PHP] Database abstraction?

2008-04-17 Thread Jason Pruim


On Apr 16, 2008, at 10:55 AM, Richard Heyes wrote:
I'm back with yet another question But getting closer to  
sounding like I know what I'm talking about and that's all thanks  
to all of you. A free beer (Or beverage of choice)* for everyone  
who has helped me over the years!


I would prefer hard (or soft) cash... :-)


Here's my question... I have a program, where I want to take out  
the field names in a database table and display them... In other  
words instead of writing:
$Query =SELECT First, Last, Middle, Add1 FROM mytable order by  
$order;

I want to write something more like:
$Query =SELECT $FIELDNAMES FROM mytable order by $order;
So I need to know how to get the field names from the database so  
that I can populate $FIELDNAMES. I played a little bit and it looks  
like I might be able to get what I want by doing 2 queries...

$QueryFieldNames = DESCRIBE $table;
And then some sort of a foreach or maybe a while to populate  
$FIELDNAMES? Maybe an array so I could do $FIELDNAMES['First'] if I  
needed to later.
then I can use my SELECT $FIELDNAMES FROM $table order by $order  
query to do my query...

Am I on the right path? Way off base? Not even in the ball park?
Hopefully it makes sense... Cause it's right on the edge of my  
knowledge so I'm not totally sure how to ask it right yet :)


You could do it adequately with a DESCRIBE, but there might be  
something that's better. I would suggest looking through the code  
of my TableEditor:


http://www.phpguru.org/static/TableEditor.html


I took a quick look at it, and quickly realized you know more then  
me :P I'll dig into it more today hopefully once the caffeine kicks in  
better and I can make a full sentence without having it take me 5  
minutes :)



--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424-9337
www.raoset.com
[EMAIL PROTECTED]




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



Re: [PHP] Database abstraction?

2008-04-17 Thread Stut

On 17 Apr 2008, at 13:33, Jason Pruim wrote:
Maybe I'm showing my ignorance here in programming... Maybe it's  
because I delt with a kid who decided to scream for a good share of  
the night and I'm sleep deprived :) But in my current system I have  
this:


echo HTML

div
table border=1
tr
tda href=?order=aFirst Name/a/td
tda href=?order=bLast Name/a/td
tda href=?order=cAddress 1/a/td
tda href=?order=dAddress 2/a/td
tda href=?order=eCity/a/td
tda href=?order=fState/a/td
tda href=?order=gZip/a/td
tda href=?order=hCode/a/td
tda href=?order=iID #/a/td
HTML;

while($row = mysqli_fetch_assoc($result)) {
//display the info using heredoc syntac
echo HTML
tr
td{$row['FName']}/td
td{$row['LName']}/td
td{$row['Add1']}/td
td{$row['Add2']}/td
td{$row['City']}/td
td{$row['State']}/td
td{$row['Zip']}/td
td{$row['XCode']}/td
td{$row['Record']}/td
HTML;
}

What I want to do is take that first block of code, the one with the  
links for sorting, and instead of this: tda href=? 
order=aFirst Name/a/td I want to put something more like  
this: tda href=?order=a$FIELDNAMES[$field{$id}]/a/td So  
I can grab the field names from the database, instead of hardcoding  
them into my program.


I think I am sleep deprived because the more I tried to clarify  
it... the harder it got for me to understand :)


echo HTML
div
table border=1\
HTML;

$first = true;
while ($row = mysqli_fetch_assoc($result)) {
if ($first)
{
echo 'tr';
foreach (array_keys($row) as $field) {
echo 'td'.htmlentities($field).'/td';
}
echo '/tr';
$first = false;
}

// Output the row here as above
}

-Stut

--
http://stut.net/

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



[PHP] kadm5

2008-04-17 Thread Donald Miller
When I try to use the Kadm5_init_with_password function, or any of the 
kerberos (kadm5) functions, I get an error that tells me that it is an 
undefined function, yet it is supposed to be part of the php core.  What 
do I need to do to use this function??

Thanks,
Donald Miller
[EMAIL PROTECTED]


Re: [PHP] kadm5

2008-04-17 Thread Daniel Brown
On Wed, Apr 16, 2008 at 1:35 PM, Donald Miller
[EMAIL PROTECTED] wrote:
 When I try to use the Kadm5_init_with_password function, or any of the
  kerberos (kadm5) functions, I get an error that tells me that it is an
  undefined function, yet it is supposed to be part of the php core.  What
  do I need to do to use this function??

  Thanks,
  Donald Miller
  [EMAIL PROTECTED]

It does indeed say that it's part of the core, but at the head of
each function page in the documentation, it mentions a PECL version,
which can be found here:

http://pecl.php.net/package/kadm5

It may be a bug in the documentation.  Checking the PHP source
should help determine that.

-- 
/Daniel P. Brown
Dedicated Servers - Intel 2.4GHz w/2TB bandwidth/mo. starting at just
$59.99/mo. with no contract!
Dedicated servers, VPS, and hosting from $2.50/mo.

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



Re: [PHP] Hack question

2008-04-17 Thread Daniel Brown
On Thu, Apr 17, 2008 at 8:15 AM, Al [EMAIL PROTECTED] wrote:
 Can you explain this in more detail for me. Sounds like this code is
 providing the entry point for the other hack code.

It probably is, by reading the code from the malicious /tmp files
(/tmp should not allow any execution, by the way).  However, more of
an issue is how the exploit code got on there in the first place.

Don't just settle for fixing an issue; solve the problem.
Otherwise, it'll just happen again and again.

-- 
/Daniel P. Brown
Dedicated Servers - Intel 2.4GHz w/2TB bandwidth/mo. starting at just
$59.99/mo. with no contract!
Dedicated servers, VPS, and hosting from $2.50/mo.

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



Re: [PHP] Database abstraction?

2008-04-17 Thread Daniel Brown
On Thu, Apr 17, 2008 at 8:38 AM, Jason Pruim [EMAIL PROTECTED] wrote:

  I took a quick look at it, and quickly realized you know more then me :P
 I'll dig into it more today hopefully once the caffeine kicks in better and
 I can make a full sentence without having it take me 5 minutes :)

For the record, it was exactly five minutes.

-- 
/Daniel P. Brown
Dedicated Servers - Intel 2.4GHz w/2TB bandwidth/mo. starting at just
$59.99/mo. with no contract!
Dedicated servers, VPS, and hosting from $2.50/mo.

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



Re: [PHP] Database abstraction?

2008-04-17 Thread Richard Heyes

Daniel Brown wrote:

On Thu, Apr 17, 2008 at 8:38 AM, Jason Pruim [EMAIL PROTECTED] wrote:

 I took a quick look at it, and quickly realized you know more then me :P
I'll dig into it more today hopefully once the caffeine kicks in better and
I can make a full sentence without having it take me 5 minutes :)


For the record, it was exactly five minutes.


What was?

--
Richard Heyes

+-+
|Access SASH through a Windows mapped drive|
|http://www.phpguru.org/sftpdrive |
+-+

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



Re: [PHP] Database abstraction?

2008-04-17 Thread Richard Heyes

 SASH

That should have been SSH of course - seems my spell checker isn't very 
technical...


--
Richard Heyes

+-+
|Access SSH through a Windows mapped drive|
|http://www.phpguru.org/sftpdrive |
+-+

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



Re: [PHP] Database abstraction?

2008-04-17 Thread Daniel Brown
On Thu, Apr 17, 2008 at 10:19 AM, Richard Heyes [EMAIL PROTECTED] wrote:
 Daniel Brown wrote:

  On Thu, Apr 17, 2008 at 8:38 AM, Jason Pruim [EMAIL PROTECTED] wrote:
 
I took a quick look at it, and quickly realized you know more then me
 :P
   I'll dig into it more today hopefully once the caffeine kicks in better
 and
   I can make a full sentence without having it take me 5 minutes :)
  
 
 For the record, it was exactly five minutes.
 

  What was?

The sentence to which he was referring was received in my inbox
exactly five minutes after the prior message, thus validating his
[jocular] statement.  ;-P

-- 
/Daniel P. Brown
Dedicated Servers - Intel 2.4GHz w/2TB bandwidth/mo. starting at just
$59.99/mo. with no contract!
Dedicated servers, VPS, and hosting from $2.50/mo.

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



Re: [PHP] Database abstraction?

2008-04-17 Thread Jason Pruim


On Apr 17, 2008, at 10:26 AM, Daniel Brown wrote:
On Thu, Apr 17, 2008 at 10:19 AM, Richard Heyes  
[EMAIL PROTECTED] wrote:

Daniel Brown wrote:

On Thu, Apr 17, 2008 at 8:38 AM, Jason Pruim [EMAIL PROTECTED]  
wrote:


I took a quick look at it, and quickly realized you know more  
then me

:P
I'll dig into it more today hopefully once the caffeine kicks in  
better

and

I can make a full sentence without having it take me 5 minutes :)



  For the record, it was exactly five minutes.



What was?


   The sentence to which he was referring was received in my inbox
exactly five minutes after the prior message, thus validating his
[jocular] statement.  ;-P


I timed it that way... Put a few delays into my mailserver just so I  
could hit the 5 minute mark :)


Now that the caffeine is kicking in I SHOULD be able to actually  
function!


--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424-9337
www.raoset.com
[EMAIL PROTECTED]




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



Re: [PHP] Database abstraction?

2008-04-17 Thread Daniel Brown
On Thu, Apr 17, 2008 at 10:24 AM, Richard Heyes [EMAIL PROTECTED] wrote:
  SASH

  That should have been SSH of course - seems my spell checker isn't very
 technical...
  +-+
  |Access SSH through a Windows mapped drive|
  |http://www.phpguru.org/sftpdrive |
  +-+

Don't feel so bad.  Mine insists nevermind and caffeinated
aren't real words, but then suggests that some technical terms and
acronyms have been suggestions.  And since no word in the English
language begins with FT, it defaults to FU and yes, my
spell-checker *does* see that as a real word.

-- 
/Daniel P. Brown
Dedicated Servers - Intel 2.4GHz w/2TB bandwidth/mo. starting at just
$59.99/mo. with no contract!
Dedicated servers, VPS, and hosting from $2.50/mo.

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



Re: [PHP] Database abstraction?

2008-04-17 Thread Richard Heyes

And since no word in the English language begins with FT


You're forgetting Ftork...

--
Richard Heyes

+-+
|Access SSH through a Windows mapped drive|
|http://www.phpguru.org/sftpdrive |
+-+

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



[PHP] FROM httpd.conf TO .htaccess

2008-04-17 Thread Alberto García Gómez
Fellows, I need to change this configuration from my httpd.conf file to an 
.htacces file so my scripts can work in any apache without having access (or 
change) the server httpd.conf file

Here's the piece of the httpd.conf

RewriteEngine On
RewriteLogLevel 9
RewriteLog logs/server.com-rewrite_log
RewriteRule ^/(.*\.html)$ /index.php?$1 [L]
RewriteRule ^/(.*\.htm)$ /index.php?$1 [L]

What I need to do is put this redirection in the .htaccess file instead the 
httpd.conf file

Re: [PHP] FROM httpd.conf TO .htaccess

2008-04-17 Thread Daniel Brown
On Thu, Apr 17, 2008 at 10:44 PM, Alberto García Gómez
[EMAIL PROTECTED] wrote:
 Fellows, I need to change this configuration from my httpd.conf file to an
  .htacces file so my scripts can work in any apache without having access (or
  change) the server httpd.conf file

  Here's the piece of the httpd.conf

  RewriteEngine On
  RewriteLogLevel 9
  RewriteLog logs/server.com-rewrite_log
  RewriteRule ^/(.*\.html)$ /index.php?$1 [L]
  RewriteRule ^/(.*\.htm)$ /index.php?$1 [L]

  What I need to do is put this redirection in the .htaccess file instead the 
 httpd.conf file

Congratulations!  That's great news!

So what's the question?  Is it not working?  It could be a matter
of overrides by server configuration in the host's httpd.conf, or
perhaps mod_rewrite isn't installed.

-- 
/Daniel P. Brown
Dedicated Servers - Intel 2.4GHz w/2TB bandwidth/mo. starting at just
$59.99/mo. with no contract!
Dedicated servers, VPS, and hosting from $2.50/mo.

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



Re: [PHP] FROM httpd.conf TO .htaccess

2008-04-17 Thread Wolf

 Alberto García Gómez [EMAIL PROTECTED] wrote: 
 Fellows, I need to change this configuration from my httpd.conf file to an 
 .htacces file so my scripts can work in any apache without having access (or 
 change) the server httpd.conf file
 
 Here's the piece of the httpd.conf
 
 RewriteEngine On
 RewriteLogLevel 9
 RewriteLog logs/server.com-rewrite_log
 RewriteRule ^/(.*\.html)$ /index.php?$1 [L]
 RewriteRule ^/(.*\.htm)$ /index.php?$1 [L]
 
 What I need to do is put this redirection in the .htaccess file instead the 
 httpd.conf file


Where's your PHP code that you are having an issue with?

Sure, some of us use apache, but this is a PHP list afterall.

What happened when you just pasted the above lines into .htaccess?



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



Re: [PHP] Database abstraction?

2008-04-17 Thread Jim Lucas

Stut wrote:

On 17 Apr 2008, at 13:33, Jason Pruim wrote:
Maybe I'm showing my ignorance here in programming... Maybe it's 
because I delt with a kid who decided to scream for a good share of 
the night and I'm sleep deprived :) But in my current system I have this:


echo HTML

div
table border=1
tr
tda href=?order=aFirst Name/a/td
tda href=?order=bLast Name/a/td
tda href=?order=cAddress 1/a/td
tda href=?order=dAddress 2/a/td
tda href=?order=eCity/a/td
tda href=?order=fState/a/td
tda href=?order=gZip/a/td
tda href=?order=hCode/a/td
tda href=?order=iID #/a/td
HTML;

while($row = mysqli_fetch_assoc($result)) {
//display the info using heredoc syntac
echo HTML
tr
td{$row['FName']}/td
td{$row['LName']}/td
td{$row['Add1']}/td
td{$row['Add2']}/td
td{$row['City']}/td
td{$row['State']}/td
td{$row['Zip']}/td
td{$row['XCode']}/td
td{$row['Record']}/td
HTML;
}

What I want to do is take that first block of code, the one with the 
links for sorting, and instead of this: tda href=?order=aFirst 
Name/a/td I want to put something more like this: tda 
href=?order=a$FIELDNAMES[$field{$id}]/a/td So I can grab the 
field names from the database, instead of hardcoding them into my 
program.


I think I am sleep deprived because the more I tried to clarify it... 
the harder it got for me to understand :)


echo HTML
div
table border=1\
HTML;

$first = true;
while ($row = mysqli_fetch_assoc($result)) {
if ($first)
{
echo 'tr';
foreach (array_keys($row) as $field) {
echo 'td'.htmlentities($field).'/td';
}
echo '/tr';
$first = false;
}

// Output the row here as above
}

-Stut



Very good example, but I would remove data retrieval from the display of data.

?php

$dataSet = array();
while ($row = mysqli_fetch_assoc($result)) {
$dataSet[] = $row;
}

# do some other stuff

# now display
# Check to see if there is anything in the dataSet
if ( count($dataSet)  0 ) {

echo 'table';

# Get the names of the columns from the first result set
$headers = array_keys($dataSet[0]);

# Print the column names
echo 'tr';
foreach ( $headers AS $column_name ) {
echo th{$column_name}/th;
}
echo '/tr';

# Now print your data
foreach ( $dataSet AS $row ) {
echo ROW
tr
td{$row['FName']}/td
td{$row['LName']}/td
td{$row['Add1']}/td
td{$row['Add2']}/td
td{$row['City']}/td
td{$row['State']}/td
td{$row['Zip']}/td
td{$row['XCode']}/td
td{$row['Record']}/td
/tr
ROW;
}
echo '/table';
}

?

--
Jim Lucas

   Some men are born to greatness, some achieve greatness,
   and some have greatness thrust upon them.

Twelfth Night, Act II, Scene V
by William Shakespeare


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



[PHP] CAN NOT read qmail

2008-04-17 Thread Yui Hiroaki
HI!

I have a question about read to qmail.

I try to read qmail using php. But I can not
read it.

the code is below-
?php

$file=213434534.domain.com;
$fp = fopen($file, r);
while(!feof($fp)) {
$data = fgets($fp, 1024);
echo $data br;
}
fclose($fp);

-

regards,
Yui

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



RE: [PHP] CAN NOT read qmail

2008-04-17 Thread Jay Blanchard
[snip]

I have a question about read to qmail.

I try to read qmail using php. But I can not
read it.

the code is below-
?php

$file=213434534.domain.com;
$fp = fopen($file, r);
while(!feof($fp)) {
$data = fgets($fp, 1024);
echo $data br;
}
fclose($fp);

-
[/snip]

Insert some basic error checking code to see if you successfully opened
the file, etc. That'll point you in the right direction. 

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



Re: [PHP] CAN NOT read qmail

2008-04-17 Thread Yui Hiroaki
I do not get it.
I do not where code has basic mistake.

I do not have any error message.
When I read qmail. My browser is stopped.

Regards,
yui

2008/4/18, Jay Blanchard [EMAIL PROTECTED]:
 [snip]


  I have a question about read to qmail.

  I try to read qmail using php. But I can not
  read it.

  the code is below-
  ?php

  $file=213434534.domain.com;
  $fp = fopen($file, r);
  while(!feof($fp)) {
  $data = fgets($fp, 1024);
  echo $data br;
  }
  fclose($fp);

  -

 [/snip]

  Insert some basic error checking code to see if you successfully opened
  the file, etc. That'll point you in the right direction.


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



RE: [PHP] CAN NOT read qmail

2008-04-17 Thread Jay Blanchard
[snip]
I do not get it.
I do not where code has basic mistake.
[/snip]

And that is why putting in basic error checking will help, for instance;

$fp = fopen($file, r);
if($fp){
while(!feof($fp)) {
$data = fgets($fp, 1024);
echo $data br;
}
} else {
die(fopen failed for $file)
}

Please spend some time reading the manual and getting the basics down.

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



Re: [PHP] What is the practical use of abstract and interface?

2008-04-17 Thread Nathan Nobbe
On Thu, Apr 17, 2008 at 3:42 AM, Robin Vickery [EMAIL PROTECTED] wrote:

 On 16/04/2008, Tony Marston [EMAIL PROTECTED] wrote:
 
 
-Original Message-
From: Robin Vickery [mailto:[EMAIL PROTECTED]
Sent: 16 April 2008 17:23
To: Jay Blanchard
Cc: Tony Marston; php-general@lists.php.net
Subject: Re: [PHP] What is the practical use of abstract
and interface?
   
   
On 16/04/2008, Jay Blanchard [EMAIL PROTECTED] wrote:
 [snip]
   What about encapsulation?

  Interfaces have nothing to do with encapsulation for the
smple reason
 that I  can have encapsulation without using interfaces.
   
Unique use of logic there.
   
By similar reasoning; swimming trunks have nothing to do with
swimming for the simple reason that I can swim without trunks.
 
 
  Correct. Encapsulation and polymorphism can be achieved without
 interfaces,
   therefore interfaces are not necessary.

 You've switched positions from have nothing to do with to not
 necessary. Prefacing your statement with Correct makes it appear
 that you're merely re-affirming your original position.

   There is nothing I can achieve with interfaces that I cannot achieve
 without
   them, therefore they are not necessary. Not only are they not
 necessary,
   because they do not add value they are totally useless.

 There's nothing that you can achieve with PHP5 that you can't achieve
 with PHP/FI either. Maybe it's time to scrap all this needless
 complexity and return to our roots.

 I've already given an example of how formally defined interfaces add
 value and you chose to dismiss it on the grounds that there's no need
 to check interfaces if you don't use interfaces. *Every* modular
 system uses interfaces whether they're formally defined or not.

   Some people seem to use them simply because they are there, or that
   was how they were taught.

 Some people don't use them because they weren't there when they
 learnt, or they weren't taught how. What's your point?

 You are still missing the fundamental point. There is absolutely
 nothing I can do WITH interfaces that I cannot do WITHOUT them,
 therefore they are redundant.
   
How about compile-time checking that the interface has been
correctly implemented?
 
 
  If you don't use interfaces there is no need for such checking.

 ok, s/interface/api/ if that makes you happier.

 If you need a concrete example, lets say your app has a nifty
 plugin system so third-parties can extend it. You have an API for
 plugins to register themselves, and each plugin exposes a set of
 methods that your application calls when necessary.

 If you define an 'interface' for your API and each plugin implements
 that interface, then if there's a plugin that doesn't implement it
 properly you'll know as soon as the plugin loads.

 If you don't formally define the interface, you're not going to know
 that the plugin's wrong until the badly implemented method gets
 called. And even then it might just introduce a hard to diagnose bug
 rather than an obvious failure.


im with  you here robin.  i think part of the issue w/ the terminology,
interface, API, modular and such is that the terms are all somewhat
abstract.  it just so happens that in php there is a concrete term as well.
this can lead to confusion.  many times in conversation, its important to
specify particularly what one is speaking about so that others may follow
ones train of thought.
and indeed, in creating an 'api' suppose a set of 'services' based on the
http prtotocol, the HTTP methods (POST, GET, PUT, DELETE [typtically]) and
the values expected to be supplied over those methods comprise and
interface.  just like a function.  i would also say that the term interface
could be used interchangeably w/ 'method signature'.  yes, there are many
things to which the term interface applies it can result in confusion during
technical conversations.

-nathan


Re: [PHP] performance issues

2008-04-17 Thread Nathan Nobbe
On Thu, Apr 17, 2008 at 12:14 AM, Robert Cummings [EMAIL PROTECTED]
wrote:

 If it's faster, it's faster so that would suggest a performance gain...
 but as many will tell you, and you most likely already know... is the
 gain worth the effort? BTW, rote replacement of references like that,
 may not be a good idea. There are times when you really do want a
 reference to an object... or maybe not... but you or someone else might
 have done it anyways ;)


im not sure if its worth the effort yet; thats sortof why im asking about it
on the list.  obviously ill risk introduction bugs, which obviously, i dont
want to do... ill have to analyze the regression system as it stands.  if
its decent, i might be able to use it as a benchmark utility and to test for
bugs after the mass conversion.

Contrast:
 ?php

$b = new Foo();
$a = $b;
$a = new Fee();

 ?

 Versus:
 ?php

$b = new Foo();
$a = $b;
$a new Fee();

 ?

 In the first $b references the instance of Fee since $a is a reference.
 In the second, $b remains an instance of Foo when $a becomes and
 instance of Fee.


wow, thats a clever example.  honestly, i dont think ive ever done that
before myself... but clearly that doesnt mean others havent in this
codebase.  thanks for the insight.

-nathan


Re: [PHP] performance issues

2008-04-17 Thread Nathan Nobbe
On Thu, Apr 17, 2008 at 4:57 AM, Bojan Tesanovic [EMAIL PROTECTED]
wrote:

 in PHP5 by default Objects are passed by reference and as you can see at
 this graph passing array by reference in PHP5 is slower
 http://nathan.moxune.com/arrayVsArrayIteratorReport.php


wow, thats hilarious, thats my own chart :O  ROTFL

im glad somebody else thought something of it ;)

-nathan


Re: [PHP] Most viewed?

2008-04-17 Thread Philip Thompson

On Apr 15, 2008, at 5:26 PM, tedd wrote:

At 10:41 AM -0500 4/15/08, Steve Marquez wrote:

Greetings,

Can any of you point me in the right direction on how to use PHP to  
create a

most viewed or most clicked articles list? Can it be done with PHP?

Thank you so much,

Steve Marquez
[EMAIL PROTECTED]


Steve:

There are a couple of ways to do this: 1) use mysql to record each  
download; 2) use a file to record each download.


All you do is pass the user's click to a php script that records the  
transaction -- incrementing a counter in either mysql or a file and  
delivers the content to the user. You can include that number in  
your html to show how many transactions, if you want.


This is an example of using a file:

http://www.webbytedd.com/b/readwrite-download/

Cheers,

tedd



If you want to take it a step further and only record a *click* if a  
person hasn't clicked this article before, you have several options.  
You can save a cookie on their computer saying they've clicked that  
article - of course they can delete the cookie, which may skew the  
count. Or you can save their IP address in a database (or file, if you  
want to choose that method) - only increment if that IP address hasn't  
clicked that article before. And of course, it's also very possible  
that their IP address can change. However, it should work pretty well.


To get you started (and for the archives)

?php
$article_id = mysql_real_escape_string ($_GET['article_id']);

// Cookie way
if (!$_COOKIE[article-$article_id]) {
setcookie  (article-$article_id, true, time()+60*60*24*365); //  
expire 1 year from now
mysql_query (UPDATE `clicked_articles` SET `article_count` =  
`article_count`+1 WHERE (`article_id` = '$article_id'));
$result = mysql_query (SELECT `article_count` FROM  
`clicked_articles`);

$clicked_count = mysql_result ($result, 0);
}

// IP-Database way
$ip = $_SERVER['REMOTE_ADDR'];
$result = mysql_query (SELECT `ip_address` FROM `clicked_articles`  
WHERE (`ip_address` = '$ip') LIMIT 1);


if (!mysql_num_rows ($result)) {
mysql_query (INSERT INTO `clicked_articles` (`article_id`,  
`ip_address`) VALUES ('$article_id', '$ip'));
$result = mysql_query (SELECT COUNT(`ip_address`) FROM  
`clicked_articles` WHERE (`article_id` = '$article_id'));

$clicked_count = mysql_result ($result, 0);
}
?

If you want to find the top 5 clicked articles, do the following  
respectively compared to above:


?php
// If using Cookies
$result = mysql_query (SELECT `article_id` FROM `clicked_articles`  
ORDER BY `article_count` DESC LIMIT 0,5);

while (list ($id) = mysql_fetch_row ($result)) {
$article_ids[] = $id;
}

// If using IPs
$result = mysql_query (SELECT COUNT(`article_id`) AS  
`article_id_count`, `article_id` FROM `clicked_articles` GROUP BY  
`article_id` ORDER BY `article_id_count` DESC LIMIT 0,5);

while (list ($count, $id) = mysql_fetch_row ($result)) {
$article_ids[] = $id;
// OR to give count for each id
$article_ids[$id] = $count;
}
?

Hope this helps. Note, the usual email-code disclaimer.

~Philip

PS... Sorry I'm two days late. Just now catching up. =D

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



Re: [PHP] Newbie question about sending email

2008-04-17 Thread Pete Holsberg

Daniel Brown has written on 4/16/2008 5:20 PM:

On Wed, Apr 16, 2008 at 5:14 PM, Pete Holsberg [EMAIL PROTECTED] wrote:
  

 Why do I need both from_addr and field_4 (Email Address)? Could I just use

 $from = $_POST['field_4']?



Sorry, I noticed it after I started rewriting the form processor,
and then forgot to edit the email accordingly.

That's correct.  Where I placed the $_POST['from_addr'] stuff,
just replace it with $_POST['field_4'].  And then, of course, you can
ignore the HTML field-adding section of my previous email


OK. Here's what I have now for processor.php:

?php

//
$where_form_is=http://.$_SERVER['SERVER_NAME'].strrev(strstr(strrev($_SERVER['PHP_SELF']),/));


$where_form_is = 
http://.$_SERVER['SERVER_NAME'].dirname($_SERVER['PHP_SELF'])./;


if (mail($to, $from, $subject, $body)) {
 echo(pMessage successfully sent!/p);
} else {
 echo(pMessage delivery failed.../p);
}

$to = [EMAIL PROTECTED],[EMAIL PROTECTED];
$subject = SUBSCRIBE;
$from = $_POST['field_4'];
$body = Form data:

Name: .$_POST['field_1'].
Street Address: .$_POST['field_2'].
Phone Number: .$_POST['field_3'].
Email Address: .$_POST['field_4'].

powered by phpFormGenerator, but fixed by PHP-General!;

$headers  = From: \.$_POST['field_1'].\ .$_POST['from_addr'].\r\n;
$headers .= X-Mailer: PHP/.phpversion().\r\n;

include(confirm.html);

?

I don't get either of the echo statements, and the emails are not being 
delivered.


What did I omit?

Thanks.

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



Re: [PHP] CAN NOT read qmail

2008-04-17 Thread Yui Hiroaki
I try your code;

It is great.
But I get faile.

It means I can not open the file, which is from qmail.
It may be different format of qmail

I get below from code
failed for 1208434346177.9690.domain.com




code---
?php
$file = 1208434346177.9690.domain.com;
$fp = fopen($file, r);
echo hello;
if($fp){
   while(!feof($fp)) {
   $data = fgets($fp, 1024);
   echo $data br;
   }
}else{
   die(fopen failed for $file);
}
?
-


If you know how to read qmail, please.

Regards,
Yui
2008/4/18, Jay Blanchard [EMAIL PROTECTED]:
 [snip]

 I do not get it.
  I do not where code has basic mistake.

 [/snip]

  And that is why putting in basic error checking will help, for instance;

  $fp = fopen($file, r);
  if($fp){

 while(!feof($fp)) {
 $data = fgets($fp, 1024);
 echo $data br;
 }

 } else {
 die(fopen failed for $file)
  }

  Please spend some time reading the manual and getting the basics down.


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



Re: [PHP] Newbie question about sending email

2008-04-17 Thread Daniel Brown
On Thu, Apr 17, 2008 at 12:17 PM, Pete Holsberg [EMAIL PROTECTED] wrote:
[snip!]

  OK. Here's what I have now for processor.php:


  ?php

  //
 $where_form_is=http://.$_SERVER['SERVER_NAME'].strrev(strstr(strrev($_SERVER['PHP_SELF']),/));

  $where_form_is =
 http://.$_SERVER['SERVER_NAME'].dirname($_SERVER['PHP_SELF'])./;

  if (mail($to, $from, $subject, $body)) {
   echo(pMessage successfully sent!/p);
  } else {
   echo(pMessage delivery failed.../p);

  }
[snip!]

I'll reiterate:
   Note the mail() parameters.  There's no header information there.
RTFM: http://php.net/mail

You just have your mail() function wrong.  Reiterating my code as
well (with updated field_4 data):

?php

$where_form_is =
http://.$_SERVER['SERVER_NAME'].dirname($_SERVER['PHP_SELF'])./;
$to = [EMAIL PROTECTED],[EMAIL PROTECTED];
$subject = SUBSCRIBE;
$from = $_POST['field_4'];
$body = Form data:

Name: .$_POST['field_1'].
Street Address: .$_POST['field_2'].
Phone Number: .$_POST['field_3'].
Email Address: .$_POST['field_4'].

powered by phpFormGenerator, but fixed by PHP-General!;

$headers  = From: \.$_POST['field_1'].\ .$_POST['field_4'].\r\n;
$headers .= X-Mailer: PHP/.phpversion().\r\n;

include(confirm.html);

?


-- 
/Daniel P. Brown
Dedicated Servers - Intel 2.4GHz w/2TB bandwidth/mo. starting at just
$59.99/mo. with no contract!
Dedicated servers, VPS, and hosting from $2.50/mo.

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



Re: [PHP] Most viewed?

2008-04-17 Thread Andrew Ballard
On Thu, Apr 17, 2008 at 12:07 PM, Philip Thompson
[EMAIL PROTECTED] wrote:
[snip]
  If you want to take it a step further and only record a *click* if a person
 hasn't clicked this article before, you have several options. You can save a
 cookie on their computer saying they've clicked that article - of course
 they can delete the cookie, which may skew the count. Or you can save their
 IP address in a database (or file, if you want to choose that method) - only
 increment if that IP address hasn't clicked that article before. And of
 course, it's also very possible that their IP address can change. However,
 it should work pretty well.

Or they could share an IP with a few hundred other people so that all
of them combined only get counted one time.

Andrew

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



Re: [PHP] Newbie question about sending email

2008-04-17 Thread Pete Holsberg

Daniel Brown has written on 4/17/2008 12:29 PM:

I'll reiterate:
   Note the mail() parameters.  There's no header information there.
RTFM: http://php.net/mail

You just have your mail() function wrong.  Reiterating my code as
well (with updated field_4 data):

?php

$where_form_is =
http://.$_SERVER['SERVER_NAME'].dirname($_SERVER['PHP_SELF'])./;
$to = [EMAIL PROTECTED],[EMAIL PROTECTED];
$subject = SUBSCRIBE;
$from = $_POST['field_4'];
$body = Form data:

Name: .$_POST['field_1'].
Street Address: .$_POST['field_2'].
Phone Number: .$_POST['field_3'].
Email Address: .$_POST['field_4'].

powered by phpFormGenerator, but fixed by PHP-General!;

$headers  = From: \.$_POST['field_1'].\ .$_POST['field_4'].\r\n;
$headers .= X-Mailer: PHP/.phpversion().\r\n;

include(confirm.html);

?


OK. I don't see a mail() in your code. Would it be

mail($to, $subject, $body, $headers);

?

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



Re: [PHP] Most viewed?

2008-04-17 Thread Richard Heyes

 If you want to take it a step further and only record a *click* if a person
hasn't clicked this article before, you have several options. You can save a
cookie on their computer saying they've clicked that article - of course
they can delete the cookie, which may skew the count. Or you can save their
IP address in a database (or file, if you want to choose that method) - only
increment if that IP address hasn't clicked that article before. And of
course, it's also very possible that their IP address can change. However,
it should work pretty well.


Or they could share an IP with a few hundred other people so that all
of them combined only get counted one time.


Because of this if it's not too important (eg it's just ratings of 
articles) personally I would choose the cookie method. If it's uber 
important you could have the user login before they can rate stuff.


--
Richard Heyes

+-+
|Access SSH through a Windows mapped drive|
|http://www.phpguru.org/sftpdrive |
+-+

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



Re: [PHP] Newbie question about sending email

2008-04-17 Thread Daniel Brown
On Thu, Apr 17, 2008 at 12:37 PM, Pete Holsberg [EMAIL PROTECTED] wrote:

  OK. I don't see a mail() in your code. Would it be

  mail($to, $subject, $body, $headers);

  ?

Entirely my fault, Pete.  I'm a moron sometimes.  Could've sworn
it was in there.  Sorry about that.

Yes, you've got it exactly right.

-- 
/Daniel P. Brown
Dedicated Servers - Intel 2.4GHz w/2TB bandwidth/mo. starting at just
$59.99/mo. with no contract!
Dedicated servers, VPS, and hosting from $2.50/mo.

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



Re: [PHP] Newbie question about sending email

2008-04-17 Thread Pete Holsberg

Ooops!

processor.php is now:


?php

$where_form_is = 
http://.$_SERVER['SERVER_NAME'].dirname($_SERVER['PHP_SELF'])./;


$to = [EMAIL PROTECTED],[EMAIL PROTECTED];
$subject = SUBSCRIBE;
//$from = $_POST['field_4'];  == this was the culprit
$body = Form data:

Name: .$_POST['field_1'].
Street Address: .$_POST['field_2'].
Phone Number: .$_POST['field_3'].
Email Address: .$_POST['field_4'].

powered by phpFormGenerator, but fixed by PHP-General!;

$headers  = From: \.$_POST['field_1'].\ .$_POST['field_4'].\r\n;
$headers .= X-Mailer: PHP/.phpversion().\r\n;

mail($to, $from, $subject, $body);

include(confirm.html);
?

AND IT WORKS!!

1E6 thank yous!!

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



RE: [PHP] CAN NOT read qmail

2008-04-17 Thread Jay Blanchard
[snip]
I try your code;

It is great.
But I get faile.
[/snip]

If you get a failure then you might not have permission to open the
file.








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



Re: [PHP] Newbie question about sending email

2008-04-17 Thread Daniel Brown
On Thu, Apr 17, 2008 at 12:50 PM, Pete Holsberg [EMAIL PROTECTED] wrote:

  1E6 thank yous!!

My TI SR-10 couldn't handle that calculation and blew up in my hand.  ;-P

-- 
/Daniel P. Brown
Dedicated Servers - Intel 2.4GHz w/2TB bandwidth/mo. starting at just
$59.99/mo. with no contract!
Dedicated servers, VPS, and hosting from $2.50/mo.

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



Re: [PHP] CAN NOT read qmail

2008-04-17 Thread Yui Hiroaki
Thank you!
the perssion is 600
even when I try to change permission.
This mail will return 600 soon.

Regards,
yui


2008/4/18, Jay Blanchard [EMAIL PROTECTED]:
 [snip]

 I try your code;

  It is great.
  But I get faile.

 [/snip]

  If you get a failure then you might not have permission to open the
  file.









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



Re: [PHP] SERVER_PORT always at 80 ?

2008-04-17 Thread Julien Pauli
I read the source yes, but my C skills are not good enought to say.
I think about an Apache problem as well, I dont see why it would have been
hardcoded into PHP source (and I cant find it hardcoded anyway ...).

I will try another language, or even another server, to see 

thx:)

Julien.P

2008/4/14 mike [EMAIL PROTECTED]:

 you should try Perl or another language. See if you can isolate it to
 Apache.
 .
 Or, you could try to track it down inside of the PHP source and see if
 for some reason it is hardcoded or incorrectly set. (However, I still
 think it's from Apache)

 On 4/14/08, Julien Pauli [EMAIL PROTECTED] wrote:
  Ok I did that, but it's the same.
  HTTP_HOST says myhost:81 , but SERVER_PORT still says 80
 
  Cheers
  Julien.P
 
  2008/4/14 mike [EMAIL PROTECTED]:
 
   I would think PHP is just passing through what it receives from
   Apache. I assume it's just passing through environment variables it
   gets from the server.
  
   Can you disable all the other ports and only have :81 running to
   ensure there is no confusion?
  
  
  
  
   On 4/14/08, Julien Pauli [EMAIL PROTECTED] wrote:
Yes it runs on 5.3 on 81 and 5.2 on 80, both phpinfo() show port
 80
   
Regards, Julien.P
  
 
 



Re: [PHP] performance issues

2008-04-17 Thread Eric Butera
On Thu, Apr 17, 2008 at 12:00 PM, Nathan Nobbe [EMAIL PROTECTED] wrote:
 On Thu, Apr 17, 2008 at 4:57 AM, Bojan Tesanovic [EMAIL PROTECTED]
  wrote:


   in PHP5 by default Objects are passed by reference and as you can see at
   this graph passing array by reference in PHP5 is slower
   http://nathan.moxune.com/arrayVsArrayIteratorReport.php


  wow, thats hilarious, thats my own chart :O  ROTFL

  im glad somebody else thought something of it ;)

  -nathan


I almost spit my water out when I saw that link directed at you.  Your
work is famous!  ;)

I don't have an actual answer as far as benchmarks go.  I've been
converting all of my sites from php4 to 5 over the past 3 months
stripping out 's as I go.  I haven't noticed any differences myself
though.  But then again I've been adding in type hints and visibility
too so I'm sure that isn't helping.

I'm always pimping Xdebug, so just remember it will show you where
your real bottlenecks are instead of guessing.  *shrug*

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



Re: [PHP] Database abstraction?

2008-04-17 Thread Jason Pruim


On Apr 17, 2008, at 11:14 AM, Jim Lucas wrote:

Stut wrote:

On 17 Apr 2008, at 13:33, Jason Pruim wrote:
Maybe I'm showing my ignorance here in programming... Maybe it's  
because I delt with a kid who decided to scream for a good share  
of the night and I'm sleep deprived :) But in my current system I  
have this:


echo HTML

   div
   table border=1
   tr
   tda href=?order=aFirst Name/a/td
   tda href=?order=bLast Name/a/td
   tda href=?order=cAddress 1/a/td
   tda href=?order=dAddress 2/a/td
   tda href=?order=eCity/a/td
   tda href=?order=fState/a/td
   tda href=?order=gZip/a/td
   tda href=?order=hCode/a/td
   tda href=?order=iID #/a/td
HTML;

   while($row = mysqli_fetch_assoc($result)) {
   //display the info using heredoc syntac
echo HTML
   tr
   td{$row['FName']}/td
   td{$row['LName']}/td
   td{$row['Add1']}/td
   td{$row['Add2']}/td
   td{$row['City']}/td
   td{$row['State']}/td
   td{$row['Zip']}/td
   td{$row['XCode']}/td
   td{$row['Record']}/td
HTML;
}

What I want to do is take that first block of code, the one with  
the links for sorting, and instead of this: tda href=? 
order=aFirst Name/a/td I want to put something more like  
this: tda href=?order=a$FIELDNAMES[$field{$id}]/a/td  
So I can grab the field names from the database, instead of  
hardcoding them into my program.


I think I am sleep deprived because the more I tried to clarify  
it... the harder it got for me to understand :)

echo HTML
   div
   table border=1\
HTML;
$first = true;
while ($row = mysqli_fetch_assoc($result)) {
   if ($first)
   {
   echo 'tr';
   foreach (array_keys($row) as $field) {
   echo 'td'.htmlentities($field).'/td';
   }
   echo '/tr';
   $first = false;
   }
   // Output the row here as above
}
-Stut


Very good example, but I would remove data retrieval from the  
display of data.


?php

$dataSet = array();
while ($row = mysqli_fetch_assoc($result)) {
$dataSet[] = $row;
}

# do some other stuff

# now display
# Check to see if there is anything in the dataSet
if ( count($dataSet)  0 ) {

echo 'table';

# Get the names of the columns from the first result set
$headers = array_keys($dataSet[0]);

# Print the column names
echo 'tr';
foreach ( $headers AS $column_name ) {
echo th{$column_name}/th;
}
echo '/tr';

# Now print your data
foreach ( $dataSet AS $row ) {
echo ROW
tr
td{$row['FName']}/td
td{$row['LName']}/td
td{$row['Add1']}/td
td{$row['Add2']}/td
td{$row['City']}/td
td{$row['State']}/td
td{$row['Zip']}/td
td{$row['XCode']}/td
td{$row['Record']}/td
/tr
ROW;
}
echo '/table';
}

?


Both ideas worked great... Thank you!

Now I do still have one question, I decided that what Jim put up  
worked a little bit better for me so I'm going off of his code, what I  
want to do now though, is take this code:


foreach ( $dataSet AS $row ) {
echo ROW
tr
td{$row['FName']}/td
td{$row['LName']}/td
td{$row['Add1']}/td
td{$row['Add2']}/td
td{$row['City']}/td
td{$row['State']}/td
td{$row['Zip']}/td
td{$row['XCode']}/td
td{$row['Record']}/td
/tr
ROW;
}


And turn it into some kind of a loop that would pull the info  
dynamically so I can have something more like this:

?PHP
while($dataSet = $num_rows) {
//print dynamic fields based off of field names
echo ROW
tr
td$dataSet['$field']/td
/tr
ROW;
}

?

And what would print on the page would be something along the lines of:
?PHP
echo TEST
tr
tdJason/td
tdPruim/td
tdMy Address/td
tdMy Other Address/td
/tr
TEST;
?

Etc. Etc. Etc. I'm trying to avoid hardcoding things like field names  
so that I can use this software for multiple customers without having  
to completely customize it for everyone since so many parts will be  
the same.


Maybe though I'm trying to abstract the wrong part of the program... I  
could do it to a few other parts and just customize this one...


Need to think about that.

Any ideas are greatly appreciated :)


--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424-9337
www.raoset.com
[EMAIL PROTECTED]




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



[PHP] module access rights

2008-04-17 Thread Alain Roger
Hi,
i face now a little issue regarding how end user can access to some modules
of my web portal.

Let imagine we have several modules (let say: mod1, mod 2, mod3) and 2 users
(usr1, usr2).
i would like to use a simple way how to established access rights for each
user to grant/forbidden access to modules.
i was thinking that a simple code like on linux could fit this need where i
could have execute/change/read access and this for each module.

for example, usr1 could have stored into DB the access rights 710 (knowing
that rights are based on mod3 | mod2 | mod1)
so usr1 :
- could execute some particular actions, change data and read data from
module 3
- could just read data for module 2
- does not have access to module 1

something similar for usr2 could be setup.

on each php pages/module, the user rights are checked and based on result,
the correct decision is taken by the web portal system.

i would like to know if such technique is a correct one, or if there is
something much more better ?

thanks a lot,

-- 
Alain

Windows XP SP2
PostgreSQL 8.2.4 / MS SQL server 2005
Apache 2.2.4
PHP 5.2.4
C# 2005-2008


Re: [PHP] Database abstraction?

2008-04-17 Thread Jim Lucas

Jason Pruim wrote:


On Apr 17, 2008, at 11:14 AM, Jim Lucas wrote:

Stut wrote:

On 17 Apr 2008, at 13:33, Jason Pruim wrote:
Maybe I'm showing my ignorance here in programming... Maybe it's 
because I delt with a kid who decided to scream for a good share of 
the night and I'm sleep deprived :) But in my current system I have 
this:


echo HTML

   div
   table border=1
   tr
   tda href=?order=aFirst Name/a/td
   tda href=?order=bLast Name/a/td
   tda href=?order=cAddress 1/a/td
   tda href=?order=dAddress 2/a/td
   tda href=?order=eCity/a/td
   tda href=?order=fState/a/td
   tda href=?order=gZip/a/td
   tda href=?order=hCode/a/td
   tda href=?order=iID #/a/td
HTML;

   while($row = mysqli_fetch_assoc($result)) {
   //display the info using heredoc syntac
echo HTML
   tr
   td{$row['FName']}/td
   td{$row['LName']}/td
   td{$row['Add1']}/td
   td{$row['Add2']}/td
   td{$row['City']}/td
   td{$row['State']}/td
   td{$row['Zip']}/td
   td{$row['XCode']}/td
   td{$row['Record']}/td
HTML;
}

What I want to do is take that first block of code, the one with the 
links for sorting, and instead of this: tda 
href=?order=aFirst Name/a/td I want to put something more 
like this: tda 
href=?order=a$FIELDNAMES[$field{$id}]/a/td So I can grab the 
field names from the database, instead of hardcoding them into my 
program.


I think I am sleep deprived because the more I tried to clarify 
it... the harder it got for me to understand :)

echo HTML
   div
   table border=1\
HTML;
$first = true;
while ($row = mysqli_fetch_assoc($result)) {
   if ($first)
   {
   echo 'tr';
   foreach (array_keys($row) as $field) {
   echo 'td'.htmlentities($field).'/td';
   }
   echo '/tr';
   $first = false;
   }
   // Output the row here as above
}
-Stut


Very good example, but I would remove data retrieval from the display 
of data.


?php

$dataSet = array();
while ($row = mysqli_fetch_assoc($result)) {
$dataSet[] = $row;
}

# do some other stuff

# now display
# Check to see if there is anything in the dataSet
if ( count($dataSet)  0 ) {

echo 'table';

# Get the names of the columns from the first result set
$headers = array_keys($dataSet[0]);

# Print the column names
echo 'tr';
foreach ( $headers AS $column_name ) {
echo th{$column_name}/th;
}
echo '/tr';

# Now print your data
foreach ( $dataSet AS $row ) {
echo ROW
tr
td{$row['FName']}/td
td{$row['LName']}/td
td{$row['Add1']}/td
td{$row['Add2']}/td
td{$row['City']}/td
td{$row['State']}/td
td{$row['Zip']}/td
td{$row['XCode']}/td
td{$row['Record']}/td
/tr
ROW;
}
echo '/table';
}

?


Both ideas worked great... Thank you!

Now I do still have one question, I decided that what Jim put up worked 
a little bit better for me so I'm going off of his code, what I want to 
do now though, is take this code:


foreach ( $dataSet AS $row ) {
echo ROW
tr
td{$row['FName']}/td
td{$row['LName']}/td
td{$row['Add1']}/td
td{$row['Add2']}/td
td{$row['City']}/td
td{$row['State']}/td
td{$row['Zip']}/td
td{$row['XCode']}/td
td{$row['Record']}/td
/tr
ROW;
}


And turn it into some kind of a loop that would pull the info 
dynamically so I can have something more like this:

?PHP
while($dataSet = $num_rows) {
//print dynamic fields based off of field names
echo ROW
tr
td$dataSet['$field']/td
/tr
ROW;
}

?

And what would print on the page would be something along the lines of:
?PHP
echo TEST
tr
tdJason/td
tdPruim/td
tdMy Address/td
tdMy Other Address/td
/tr
TEST;
?

Etc. Etc. Etc. I'm trying to avoid hardcoding things like field names so 
that I can use this software for multiple customers without having to 
completely customize it for everyone since so many parts will be the same.


Maybe though I'm trying to abstract the wrong part of the program... I 
could do it to a few other parts and just customize this one...


Need to think about that.

Any ideas are greatly appreciated :)


--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424-9337
www.raoset.com
[EMAIL PROTECTED]





This would do it.

foreach ( $dataSet AS $row ) {
echo 'trtd.join('/tdtd', $row).'/td/tr';
}

--
Jim Lucas

   Some men are born to greatness, some achieve greatness,
   and some have greatness thrust upon them.

Twelfth Night, Act II, Scene V
by William Shakespeare


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



Re: [PHP] Database abstraction?

2008-04-17 Thread Jason Pruim


On Apr 17, 2008, at 2:12 PM, Jim Lucas wrote:

Jason Pruim wrote:

On Apr 17, 2008, at 11:14 AM, Jim Lucas wrote:

Stut wrote:



[/snip]




Both ideas worked great... Thank you!
Now I do still have one question, I decided that what Jim put up  
worked a little bit better for me so I'm going off of his code,  
what I want to do now though, is take this code:

   foreach ( $dataSet AS $row ) {
echo ROW
   tr
   td{$row['FName']}/td
   td{$row['LName']}/td
   td{$row['Add1']}/td
   td{$row['Add2']}/td
   td{$row['City']}/td
   td{$row['State']}/td
   td{$row['Zip']}/td
   td{$row['XCode']}/td
   td{$row['Record']}/td
   /tr
ROW;
   }
And turn it into some kind of a loop that would pull the info  
dynamically so I can have something more like this:

?PHP
while($dataSet = $num_rows) {
   //print dynamic fields based off of field names
echo ROW
   tr
td$dataSet['$field']/td
/tr
ROW;
}
?
And what would print on the page would be something along the lines  
of:

?PHP
echo TEST
tr
tdJason/td
tdPruim/td
tdMy Address/td
tdMy Other Address/td
/tr
TEST;
?
Etc. Etc. Etc. I'm trying to avoid hardcoding things like field  
names so that I can use this software for multiple customers  
without having to completely customize it for everyone since so  
many parts will be the same.
Maybe though I'm trying to abstract the wrong part of the  
program... I could do it to a few other parts and just customize  
this one...

Need to think about that.
Any ideas are greatly appreciated :)
--
Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424-9337
www.raoset.com
[EMAIL PROTECTED]


This would do it.

foreach ( $dataSet AS $row ) {
echo 'trtd.join('/tdtd', $row).'/td/tr';
}


Okay so that worked perfectly... NOW... Care to tell me why? :) Or  
point me to the right area?




--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424-9337
www.raoset.com
[EMAIL PROTECTED]




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



Re: [PHP] Database abstraction?

2008-04-17 Thread Jim Lucas

Jim Lucas wrote:

Jason Pruim wrote:


On Apr 17, 2008, at 11:14 AM, Jim Lucas wrote:

Stut wrote:

On 17 Apr 2008, at 13:33, Jason Pruim wrote:
Maybe I'm showing my ignorance here in programming... Maybe it's 
because I delt with a kid who decided to scream for a good share of 
the night and I'm sleep deprived :) But in my current system I have 
this:


echo HTML

   div
   table border=1
   tr
   tda href=?order=aFirst Name/a/td
   tda href=?order=bLast Name/a/td
   tda href=?order=cAddress 1/a/td
   tda href=?order=dAddress 2/a/td
   tda href=?order=eCity/a/td
   tda href=?order=fState/a/td
   tda href=?order=gZip/a/td
   tda href=?order=hCode/a/td
   tda href=?order=iID #/a/td
HTML;

   while($row = mysqli_fetch_assoc($result)) {
   //display the info using heredoc syntac
echo HTML
   tr
   td{$row['FName']}/td
   td{$row['LName']}/td
   td{$row['Add1']}/td
   td{$row['Add2']}/td
   td{$row['City']}/td
   td{$row['State']}/td
   td{$row['Zip']}/td
   td{$row['XCode']}/td
   td{$row['Record']}/td
HTML;
}

What I want to do is take that first block of code, the one with 
the links for sorting, and instead of this: tda 
href=?order=aFirst Name/a/td I want to put something more 
like this: tda 
href=?order=a$FIELDNAMES[$field{$id}]/a/td So I can grab 
the field names from the database, instead of hardcoding them into 
my program.


I think I am sleep deprived because the more I tried to clarify 
it... the harder it got for me to understand :)

echo HTML
   div
   table border=1\
HTML;
$first = true;
while ($row = mysqli_fetch_assoc($result)) {
   if ($first)
   {
   echo 'tr';
   foreach (array_keys($row) as $field) {
   echo 'td'.htmlentities($field).'/td';
   }
   echo '/tr';
   $first = false;
   }
   // Output the row here as above
}
-Stut


Very good example, but I would remove data retrieval from the display 
of data.


?php

$dataSet = array();
while ($row = mysqli_fetch_assoc($result)) {
$dataSet[] = $row;
}

# do some other stuff

# now display
# Check to see if there is anything in the dataSet
if ( count($dataSet)  0 ) {

echo 'table';

# Get the names of the columns from the first result set
$headers = array_keys($dataSet[0]);

# Print the column names
echo 'tr';
foreach ( $headers AS $column_name ) {
echo th{$column_name}/th;
}
echo '/tr';

# Now print your data
foreach ( $dataSet AS $row ) {
echo ROW
tr
td{$row['FName']}/td
td{$row['LName']}/td
td{$row['Add1']}/td
td{$row['Add2']}/td
td{$row['City']}/td
td{$row['State']}/td
td{$row['Zip']}/td
td{$row['XCode']}/td
td{$row['Record']}/td
/tr
ROW;
}
echo '/table';
}

?


Both ideas worked great... Thank you!

Now I do still have one question, I decided that what Jim put up 
worked a little bit better for me so I'm going off of his code, what I 
want to do now though, is take this code:


foreach ( $dataSet AS $row ) {
echo ROW
tr
td{$row['FName']}/td
td{$row['LName']}/td
td{$row['Add1']}/td
td{$row['Add2']}/td
td{$row['City']}/td
td{$row['State']}/td
td{$row['Zip']}/td
td{$row['XCode']}/td
td{$row['Record']}/td
/tr
ROW;
}


And turn it into some kind of a loop that would pull the info 
dynamically so I can have something more like this:

?PHP
while($dataSet = $num_rows) {
//print dynamic fields based off of field names
echo ROW
tr
td$dataSet['$field']/td
/tr
ROW;
}

?

And what would print on the page would be something along the lines of:
?PHP
echo TEST
tr
tdJason/td
tdPruim/td
tdMy Address/td
tdMy Other Address/td
/tr
TEST;
?

Etc. Etc. Etc. I'm trying to avoid hardcoding things like field names 
so that I can use this software for multiple customers without having 
to completely customize it for everyone since so many parts will be 
the same.


Maybe though I'm trying to abstract the wrong part of the program... I 
could do it to a few other parts and just customize this one...


Need to think about that.

Any ideas are greatly appreciated :)


--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424-9337
www.raoset.com
[EMAIL PROTECTED]





This would do it.

foreach ( $dataSet AS $row ) {
echo 'trtd.join('/tdtd', $row).'/td/tr';
}



I should shoot my own foot, you should encode the values before you do this.

Something like this would do the job

foreach ( $dataSet AS $row ) {
echo 'trtd;
echo join('/tdtd', array_map('htmlentities', $row));
echo '/td/tr';
}


--
Jim Lucas

   Some men are born to greatness, some achieve greatness,
   and some have greatness thrust upon them.

Twelfth Night, Act II, Scene V
by 

Re: [PHP] Database abstraction?

2008-04-17 Thread Jim Lucas

Jason Pruim wrote:


On Apr 17, 2008, at 2:12 PM, Jim Lucas wrote:

Jason Pruim wrote:

On Apr 17, 2008, at 11:14 AM, Jim Lucas wrote:

Stut wrote:



[/snip]




Both ideas worked great... Thank you!
Now I do still have one question, I decided that what Jim put up 
worked a little bit better for me so I'm going off of his code, what 
I want to do now though, is take this code:

   foreach ( $dataSet AS $row ) {
echo ROW
   tr
   td{$row['FName']}/td
   td{$row['LName']}/td
   td{$row['Add1']}/td
   td{$row['Add2']}/td
   td{$row['City']}/td
   td{$row['State']}/td
   td{$row['Zip']}/td
   td{$row['XCode']}/td
   td{$row['Record']}/td
   /tr
ROW;
   }
And turn it into some kind of a loop that would pull the info 
dynamically so I can have something more like this:

?PHP
while($dataSet = $num_rows) {
   //print dynamic fields based off of field names
echo ROW
   tr
td$dataSet['$field']/td
/tr
ROW;
}
?
And what would print on the page would be something along the lines of:
?PHP
echo TEST
tr
tdJason/td
tdPruim/td
tdMy Address/td
tdMy Other Address/td
/tr
TEST;
?
Etc. Etc. Etc. I'm trying to avoid hardcoding things like field names 
so that I can use this software for multiple customers without having 
to completely customize it for everyone since so many parts will be 
the same.
Maybe though I'm trying to abstract the wrong part of the program... 
I could do it to a few other parts and just customize this one...

Need to think about that.
Any ideas are greatly appreciated :)
--
Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424-9337
www.raoset.com
[EMAIL PROTECTED]


This would do it.

foreach ( $dataSet AS $row ) {
echo 'trtd.join('/tdtd', $row).'/td/tr';
}


Okay so that worked perfectly... NOW... Care to tell me why? :) Or point 
me to the right area?




read up on join() it is a nice tool for this.

http://www.php.net/join

basically it takes all the values of the given array and squeezes them into a 
single string.  between each value it will stick whatever you give join in the 
first argument.


I noticed a typo in the above code.  Probably noticed that didn't ya?

read the reply to myself for a better example of how to do this.




--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424-9337
www.raoset.com
[EMAIL PROTECTED]






--
Jim Lucas

   Some men are born to greatness, some achieve greatness,
   and some have greatness thrust upon them.

Twelfth Night, Act II, Scene V
by William Shakespeare


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



Re: [PHP] Database abstraction?

2008-04-17 Thread Jim Lucas

Jim Lucas wrote:

Jim Lucas wrote:

Jason Pruim wrote:


On Apr 17, 2008, at 11:14 AM, Jim Lucas wrote:

Stut wrote:

On 17 Apr 2008, at 13:33, Jason Pruim wrote:
Maybe I'm showing my ignorance here in programming... Maybe it's 
because I delt with a kid who decided to scream for a good share 
of the night and I'm sleep deprived :) But in my current system I 
have this:


echo HTML

   div
   table border=1
   tr
   tda href=?order=aFirst Name/a/td
   tda href=?order=bLast Name/a/td
   tda href=?order=cAddress 1/a/td
   tda href=?order=dAddress 2/a/td
   tda href=?order=eCity/a/td
   tda href=?order=fState/a/td
   tda href=?order=gZip/a/td
   tda href=?order=hCode/a/td
   tda href=?order=iID #/a/td
HTML;

   while($row = mysqli_fetch_assoc($result)) {
   //display the info using heredoc syntac
echo HTML
   tr
   td{$row['FName']}/td
   td{$row['LName']}/td
   td{$row['Add1']}/td
   td{$row['Add2']}/td
   td{$row['City']}/td
   td{$row['State']}/td
   td{$row['Zip']}/td
   td{$row['XCode']}/td
   td{$row['Record']}/td
HTML;
}

What I want to do is take that first block of code, the one with 
the links for sorting, and instead of this: tda 
href=?order=aFirst Name/a/td I want to put something more 
like this: tda 
href=?order=a$FIELDNAMES[$field{$id}]/a/td So I can grab 
the field names from the database, instead of hardcoding them into 
my program.


I think I am sleep deprived because the more I tried to clarify 
it... the harder it got for me to understand :)

echo HTML
   div
   table border=1\
HTML;
$first = true;
while ($row = mysqli_fetch_assoc($result)) {
   if ($first)
   {
   echo 'tr';
   foreach (array_keys($row) as $field) {
   echo 'td'.htmlentities($field).'/td';
   }
   echo '/tr';
   $first = false;
   }
   // Output the row here as above
}
-Stut


Very good example, but I would remove data retrieval from the 
display of data.


?php

$dataSet = array();
while ($row = mysqli_fetch_assoc($result)) {
$dataSet[] = $row;
}

# do some other stuff

# now display
# Check to see if there is anything in the dataSet
if ( count($dataSet)  0 ) {

echo 'table';

# Get the names of the columns from the first result set
$headers = array_keys($dataSet[0]);

# Print the column names
echo 'tr';
foreach ( $headers AS $column_name ) {
echo th{$column_name}/th;
}
echo '/tr';

# Now print your data
foreach ( $dataSet AS $row ) {
echo ROW
tr
td{$row['FName']}/td
td{$row['LName']}/td
td{$row['Add1']}/td
td{$row['Add2']}/td
td{$row['City']}/td
td{$row['State']}/td
td{$row['Zip']}/td
td{$row['XCode']}/td
td{$row['Record']}/td
/tr
ROW;
}
echo '/table';
}

?


Both ideas worked great... Thank you!

Now I do still have one question, I decided that what Jim put up 
worked a little bit better for me so I'm going off of his code, what 
I want to do now though, is take this code:


foreach ( $dataSet AS $row ) {
echo ROW
tr
td{$row['FName']}/td
td{$row['LName']}/td
td{$row['Add1']}/td
td{$row['Add2']}/td
td{$row['City']}/td
td{$row['State']}/td
td{$row['Zip']}/td
td{$row['XCode']}/td
td{$row['Record']}/td
/tr
ROW;
}


And turn it into some kind of a loop that would pull the info 
dynamically so I can have something more like this:

?PHP
while($dataSet = $num_rows) {
//print dynamic fields based off of field names
echo ROW
tr
td$dataSet['$field']/td
/tr
ROW;
}

?

And what would print on the page would be something along the lines of:
?PHP
echo TEST
tr
tdJason/td
tdPruim/td
tdMy Address/td
tdMy Other Address/td
/tr
TEST;
?

Etc. Etc. Etc. I'm trying to avoid hardcoding things like field names 
so that I can use this software for multiple customers without having 
to completely customize it for everyone since so many parts will be 
the same.


Maybe though I'm trying to abstract the wrong part of the program... 
I could do it to a few other parts and just customize this one...


Need to think about that.

Any ideas are greatly appreciated :)


--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424-9337
www.raoset.com
[EMAIL PROTECTED]





This would do it.

foreach ( $dataSet AS $row ) {
echo 'trtd.join('/tdtd', $row).'/td/tr';
}



I should shoot my own foot, you should encode the values before you do 
this.


Something like this would do the job

foreach ( $dataSet AS $row ) {
echo 'trtd;
echo join('/tdtd', array_map('htmlentities', $row));
echo '/td/tr';
}




Shoot, same typo

add a single quote at the end of the first echo line

--
Jim Lucas

   Some men are born to greatness, some achieve 

Re: [PHP] Database abstraction?

2008-04-17 Thread Jason Pruim


On Apr 17, 2008, at 2:22 PM, Jim Lucas wrote:

Jim Lucas wrote:

Jim Lucas wrote:

Jason Pruim wrote:


On Apr 17, 2008, at 11:14 AM, Jim Lucas wrote:

Stut wrote:

On 17 Apr 2008, at 13:33, Jason Pruim wrote:
Maybe I'm showing my ignorance here in programming... Maybe  
it's because I delt with a kid who decided to scream for a  
good share of the night and I'm sleep deprived :) But in my  
current system I have this:


echo HTML

  div
  table border=1
  tr
  tda href=?order=aFirst Name/a/td
  tda href=?order=bLast Name/a/td
  tda href=?order=cAddress 1/a/td
  tda href=?order=dAddress 2/a/td
  tda href=?order=eCity/a/td
  tda href=?order=fState/a/td
  tda href=?order=gZip/a/td
  tda href=?order=hCode/a/td
  tda href=?order=iID #/a/td
HTML;

  while($row = mysqli_fetch_assoc($result)) {
  //display the info using heredoc syntac
echo HTML
  tr
  td{$row['FName']}/td
  td{$row['LName']}/td
  td{$row['Add1']}/td
  td{$row['Add2']}/td
  td{$row['City']}/td
  td{$row['State']}/td
  td{$row['Zip']}/td
  td{$row['XCode']}/td
  td{$row['Record']}/td
HTML;
}

What I want to do is take that first block of code, the one  
with the links for sorting, and instead of this: tda  
href=?order=aFirst Name/a/td I want to put something  
more like this: tda href=?order=a 
$FIELDNAMES[$field{$id}]/a/td So I can grab the field  
names from the database, instead of hardcoding them into my  
program.


I think I am sleep deprived because the more I tried to  
clarify it... the harder it got for me to understand :)

echo HTML
  div
  table border=1\
HTML;
$first = true;
while ($row = mysqli_fetch_assoc($result)) {
  if ($first)
  {
  echo 'tr';
  foreach (array_keys($row) as $field) {
  echo 'td'.htmlentities($field).'/td';
  }
  echo '/tr';
  $first = false;
  }
  // Output the row here as above
}
-Stut


Very good example, but I would remove data retrieval from the  
display of data.


?php

$dataSet = array();
while ($row = mysqli_fetch_assoc($result)) {
   $dataSet[] = $row;
}

# do some other stuff

# now display
# Check to see if there is anything in the dataSet
if ( count($dataSet)  0 ) {

   echo 'table';

   # Get the names of the columns from the first result set
   $headers = array_keys($dataSet[0]);

   # Print the column names
   echo 'tr';
   foreach ( $headers AS $column_name ) {
   echo th{$column_name}/th;
   }
   echo '/tr';

   # Now print your data
   foreach ( $dataSet AS $row ) {
   echo ROW
   tr
   td{$row['FName']}/td
   td{$row['LName']}/td
   td{$row['Add1']}/td
   td{$row['Add2']}/td
   td{$row['City']}/td
   td{$row['State']}/td
   td{$row['Zip']}/td
   td{$row['XCode']}/td
   td{$row['Record']}/td
   /tr
ROW;
   }
   echo '/table';
}

?


Both ideas worked great... Thank you!

Now I do still have one question, I decided that what Jim put up  
worked a little bit better for me so I'm going off of his code,  
what I want to do now though, is take this code:


   foreach ( $dataSet AS $row ) {
echo ROW
   tr
   td{$row['FName']}/td
   td{$row['LName']}/td
   td{$row['Add1']}/td
   td{$row['Add2']}/td
   td{$row['City']}/td
   td{$row['State']}/td
   td{$row['Zip']}/td
   td{$row['XCode']}/td
   td{$row['Record']}/td
   /tr
ROW;
   }


And turn it into some kind of a loop that would pull the info  
dynamically so I can have something more like this:

?PHP
while($dataSet = $num_rows) {
   //print dynamic fields based off of field names
echo ROW
   tr
td$dataSet['$field']/td
/tr
ROW;
}

?

And what would print on the page would be something along the  
lines of:

?PHP
echo TEST
tr
tdJason/td
tdPruim/td
tdMy Address/td
tdMy Other Address/td
/tr
TEST;
?

Etc. Etc. Etc. I'm trying to avoid hardcoding things like field  
names so that I can use this software for multiple customers  
without having to completely customize it for everyone since so  
many parts will be the same.


Maybe though I'm trying to abstract the wrong part of the  
program... I could do it to a few other parts and just customize  
this one...


Need to think about that.

Any ideas are greatly appreciated :)


--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424-9337
www.raoset.com
[EMAIL PROTECTED]





This would do it.

foreach ( $dataSet AS $row ) {
   echo 'trtd.join('/tdtd', $row).'/td/tr';
}

I should shoot my own foot, you should encode the values before you  
do this.

Something like this would do the job
foreach ( $dataSet AS $row ) {
   echo 'trtd;
   echo join('/tdtd', array_map('htmlentities', $row));
   echo '/td/tr';
}


Shoot, same typo

add a single quote at the end of the first echo line


I did notice that, it was an easy fix :)

I'll definitely be reading up on 

[PHP] PHP console script vs C/C++/C#

2008-04-17 Thread Daniel Kolbo

Hello,

I am writing a PHP script for a local application (not web/html based). 
 My script is taking a longer time to execute than I want.  The source 
code is a few thousand lines, so I will spare you all this level of 
detail.


I prefer to write in PHP because that is what I know best.  However, I 
do not think there is anything inherent with my script that requires PHP 
over C/C++/C#.


If I wrote the console application in a c language (and compiled) would 
one expect to see any improvements in performance?  If so, how much 
improvement could one expect (in general)?


I assume because php is not compiled that this real time interpretation 
of the script by the zend engine must take some time.  This is why I am 
thinking about rewriting my whole script in a C language.  But before I 
begin that ordeal, i wanted to ask the community for their opinions.  If 
you think using a c language would suit me well, what language would you 
recommend?


My google and mail archive searching for this yielded mainly PHP for web 
apps, so I am asking all of you.


My main question is, how much of an improvement in performance will one 
see by using a compiled version of an application versus using a 
scripted version of an application?


I looked at PHP's bcompiler, but the documentation is minimal so I am 
hesitant to dig much deeper into that, unless someone strongly suggests 
otherwise.


Thank you PHPeeps,
DanK

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



Re: [PHP] PHP console script vs C/C++/C#

2008-04-17 Thread Nathan Nobbe
On Thu, Apr 17, 2008 at 3:30 PM, Daniel Kolbo [EMAIL PROTECTED] wrote:

 Hello,

 I am writing a PHP script for a local application (not web/html based).
  My script is taking a longer time to execute than I want.  The source code
 is a few thousand lines, so I will spare you all this level of detail.

 I prefer to write in PHP because that is what I know best.  However, I do
 not think there is anything inherent with my script that requires PHP over
 C/C++/C#.

 If I wrote the console application in a c language (and compiled) would
 one expect to see any improvements in performance?  If so, how much
 improvement could one expect (in general)?

 I assume because php is not compiled that this real time interpretation of
 the script by the zend engine must take some time.  This is why I am
 thinking about rewriting my whole script in a C language.  But before I
 begin that ordeal, i wanted to ask the community for their opinions.  If you
 think using a c language would suit me well, what language would you
 recommend?

 My google and mail archive searching for this yielded mainly PHP for web
 apps, so I am asking all of you.

 My main question is, how much of an improvement in performance will one
 see by using a compiled version of an application versus using a scripted
 version of an application?

 I looked at PHP's bcompiler, but the documentation is minimal so I am
 hesitant to dig much deeper into that, unless someone strongly suggests
 otherwise.


here you can c php is much slower than a compiled alternative:

http://shootout.alioth.debian.org/gp4/benchmark.php?test=alllang=all

-nathan


Re: [PHP] performance issues

2008-04-17 Thread Nathan Nobbe
On Thu, Apr 17, 2008 at 11:51 AM, Eric Butera [EMAIL PROTECTED] wrote:

 On Thu, Apr 17, 2008 at 12:00 PM, Nathan Nobbe [EMAIL PROTECTED]
 wrote:
  On Thu, Apr 17, 2008 at 4:57 AM, Bojan Tesanovic [EMAIL PROTECTED]
   wrote:
 
 
in PHP5 by default Objects are passed by reference and as you can see
 at
this graph passing array by reference in PHP5 is slower
http://nathan.moxune.com/arrayVsArrayIteratorReport.php
 
 
   wow, thats hilarious, thats my own chart :O  ROTFL
 
   im glad somebody else thought something of it ;)
 
   -nathan
 

 I almost spit my water out when I saw that link directed at you.


good times!


  Your
 work is famous!  ;)


well i do what i can :D

I don't have an actual answer as far as benchmarks go.  I've been
 converting all of my sites from php4 to 5 over the past 3 months
 stripping out 's as I go.  I haven't noticed any differences myself
 though.  But then again I've been adding in type hints and visibility
 too so I'm sure that isn't helping.


yea; i hadnt thought of the overhead of adding visibility / type hinting
in.  but if im adding those, either way; the extra cost from the  can be
gained back if theyre yanked.

I'm always pimping Xdebug, so just remember it will show you where
 your real bottlenecks are instead of guessing.  *shrug*


xdebug is da bomb; thats what i used to build the charts from the
performance report ;)

ok, so heres what im thinking.  any functions that return by reference can
safely be changed, right?  so i could do a mass replace like this

find: 'function '
replace: 'function '

note, there is a space after function in the replace.  i think the only
reason to use return by reference is when returning an object to avoid
getting a copy back in the php4 days.  the rest im thinking can be done by
hand as time goes on.  waddya all think?

thx,

-nathan


[PHP] loop inside a loop

2008-04-17 Thread Alan Willsher
Hi can you put a loop inside a loop?

what I want to do is have something looping every 1 second and then
something else looping once every 10 seconds.

something like a combination of these two..

$x = 0;
while ($x  1000) {
echo 1;
$x++;
sleep(1);
}

$y = 0;
while ($y  100) {
echo 2;
$y++;
sleep(10);
}

but at the same time so it would output something like

11211211212

Thanks


Re: [PHP] loop inside a loop

2008-04-17 Thread TG

Yup.. you can do that.   Easiest way to find out is to give it a try :)

As long as your loop conditions don't conflict or you do stuff to change 
variables in a counter-productive way (ie. breaking your logic) then you 
should be ok.

-TG

- Original Message -
From: Alan Willsher [EMAIL PROTECTED]
To: php-general@lists.php.net
Date: Fri, 18 Apr 2008 02:51:02 +0100
Subject: [PHP] loop inside a loop

 Hi can you put a loop inside a loop?
 
 what I want to do is have something looping every 1 second and then
 something else looping once every 10 seconds.
 
 something like a combination of these two..
 
 $x = 0;
 while ($x  1000) {
 echo 1;
 $x++;
 sleep(1);
 }
 
 $y = 0;
 while ($y  100) {
 echo 2;
 $y++;
 sleep(10);
 }
 
 but at the same time so it would output something like
 
 11211211212
 
 Thanks
 
 

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



Re: [PHP] loop inside a loop

2008-04-17 Thread Casey
On Thu, Apr 17, 2008 at 6:51 PM, Alan Willsher
[EMAIL PROTECTED] wrote:
 Hi can you put a loop inside a loop?

  what I want to do is have something looping every 1 second and then
  something else looping once every 10 seconds.

  something like a combination of these two..

  $x = 0;
  while ($x  1000) {
  echo 1;
  $x++;
  sleep(1);
  }

  $y = 0;
  while ($y  100) {
  echo 2;
  $y++;
  sleep(10);
  }

  but at the same time so it would output something like

  11211211212

  Thanks

?php
$x = 0;
while ($x  1000) {
  echo 1;
  $x++;
  if ($x % 10 == 9)
   echo 2;
  sleep(1);
}
?
:)
-- 
-Casey

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



Re: [PHP] performance issues

2008-04-17 Thread Eric Butera
On Thu, Apr 17, 2008 at 7:10 PM, Nathan Nobbe [EMAIL PROTECTED] wrote:
 On Thu, Apr 17, 2008 at 11:51 AM, Eric Butera [EMAIL PROTECTED] wrote:

 
 
 
  On Thu, Apr 17, 2008 at 12:00 PM, Nathan Nobbe [EMAIL PROTECTED]
 wrote:
   On Thu, Apr 17, 2008 at 4:57 AM, Bojan Tesanovic [EMAIL PROTECTED]
wrote:
  
  
 in PHP5 by default Objects are passed by reference and as you can see
 at
 this graph passing array by reference in PHP5 is slower
 http://nathan.moxune.com/arrayVsArrayIteratorReport.php
  
  
wow, thats hilarious, thats my own chart :O  ROTFL
  
im glad somebody else thought something of it ;)
  
-nathan
  
 
  I almost spit my water out when I saw that link directed at you.

 good times!

   Your
  work is famous!  ;)

 well i do what i can :D


  I don't have an actual answer as far as benchmarks go.  I've been
  converting all of my sites from php4 to 5 over the past 3 months
  stripping out 's as I go.  I haven't noticed any differences myself
  though.  But then again I've been adding in type hints and visibility
  too so I'm sure that isn't helping.

 yea; i hadnt thought of the overhead of adding visibility / type hinting in.
 but if im adding those, either way; the extra cost from the  can be gained
 back if theyre yanked.


  I'm always pimping Xdebug, so just remember it will show you where
  your real bottlenecks are instead of guessing.  *shrug*

 xdebug is da bomb; thats what i used to build the charts from the
 performance report ;)

 ok, so heres what im thinking.  any functions that return by reference can
 safely be changed, right?  so i could do a mass replace like this

 find: 'function '
 replace: 'function '

 note, there is a space after function in the replace.  i think the only
 reason to use return by reference is when returning an object to avoid
 getting a copy back in the php4 days.  the rest im thinking can be done by
 hand as time goes on.  waddya all think?

 thx,

 -nathan


Should be ok, but that is what unit tests are for, right?  ;)  I only
used return by reference when returning objects.  I think referencing
array inputs would be more of a challenge if there was any trickery
going on there.  The return value should just be a final here you go
since the function is done at that point.  Guess you'll find out when
you try it.  Just make a backup first! :)

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



Re: [PHP] PHP console script vs C/C++/C#

2008-04-17 Thread Eric Butera
On Thu, Apr 17, 2008 at 5:30 PM, Daniel Kolbo [EMAIL PROTECTED] wrote:
 Hello,

  I am writing a PHP script for a local application (not web/html based).  My
 script is taking a longer time to execute than I want.  The source code is a
 few thousand lines, so I will spare you all this level of detail.

  I prefer to write in PHP because that is what I know best.  However, I do
 not think there is anything inherent with my script that requires PHP over
 C/C++/C#.

  If I wrote the console application in a c language (and compiled) would one
 expect to see any improvements in performance?  If so, how much improvement
 could one expect (in general)?

  I assume because php is not compiled that this real time interpretation of
 the script by the zend engine must take some time.  This is why I am
 thinking about rewriting my whole script in a C language.  But before I
 begin that ordeal, i wanted to ask the community for their opinions.  If you
 think using a c language would suit me well, what language would you
 recommend?

  My google and mail archive searching for this yielded mainly PHP for web
 apps, so I am asking all of you.

  My main question is, how much of an improvement in performance will one see
 by using a compiled version of an application versus using a scripted
 version of an application?

  I looked at PHP's bcompiler, but the documentation is minimal so I am
 hesitant to dig much deeper into that, unless someone strongly suggests
 otherwise.

  Thank you PHPeeps,
  DanK

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



You might take a look at this:

http://us2.php.net/manual/en/function.apc-compile-file.php

I'm not sure if that works on the cli version though.  If you wanted
to start making your app faster, just find where your real bottlenecks
are and you can migrate those specific chunks into extensions.  Like
for instance if your app does a lot of text processing, you can
migrate that specific set of functions into c since it will be much
faster.  If the whole thing is just really slow maybe you should
consider why you've got such a heavy program.

Good luck on your choice!

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



RE: [PHP] FRench characters not displayed correctly

2008-04-17 Thread Ford, Mike
On 17 April 2008 10:05, Robert Cummings advised:

 On Thu, 2008-04-17 at 10:57 +0200, Angelo Zanetti wrote:
 
 Thanks Robert,
 
 I have the following headers:
 
 
 http://fr..com/student/themes/english/locker_room/student.html
 
 GET /student/themes/english/locker_room/student.html? HTTP/1.1 Host:
 fr..com User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1;
en-US;
 rv:1.8.1.14) Gecko/20080404 Firefox/2.0.0.14
 Accept:
 
 text/xml,application/xml,application/xhtml+xml,text/html;q=0.9
 ,text/plain;q=
 0.8,image/png,*/*;q=0.5
 Accept-Language: en-us,en;q=0.5
 Accept-Encoding: gzip,deflate
 Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
 Keep-Alive: 300
 Connection: keep-alive
 Referer:
 http://fr..com/student/themes/english/locker_room/student.html
 Cookie: PHPSESSID=818678404c170c8e4f5d237c1d0280a8
 If-Modified-Since: Sat, 17 Nov 2007 11:40:26 GMT
 If-None-Match: 6b97e-a9d-619b9e80
 Cache-Control: max-age=0
 
 HTTP/1.x 304 Not Modified
 Date: Thu, 17 Apr 2008 08:31:32 GMT
 Server: Apache/2.0.55 (Unix) PHP/5.1.2
 Connection: Keep-Alive
 Keep-Alive: timeout=15, max=200
 Etag: 6b97e-a9d-619b9e80
 -
 
 
 Now I see that the headers have:
 
 Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
 
 Which to me seems like it is sending both ISO-8859-1 and UTF-8?
 
 No, that's what kind of content the server is willing to accept from
 various sources such as POST.

Er, no, that's what kind of content the browser is prepared to accept
back from the server -- the headers starting from the GET line are what
the browser sends to the server as part of the request.  The lines
starting at the HTTP/1.x line are what the server returns.

In this case, you're getting a 304 Not Modified, which means the server
is not even serving any content on this request, nor, probably, even a
full set of headers -- it's just telling the browser it can use its
cached page.  To be absolutely sure what the relevant headers are, you
need to force the server to send the full page -- usually, the best way
to do this is to hold down the Ctrl key whilst clicking the
Refresh/Reload button.

Incidentally, I notice that what's being served here is a .html page,
and the presence of a 304 response, and no PHP headers, suggests it
actually is plain HTML, and not a disguised script, so this whole thread
is really very OT...!! ;)  However, this being the case, it suggests you
have a static .html file on your site claiming to be charset=utf-8, but
not saved in UTF-8!  There are two obvious ways to solve this: (i)
convert the file into UTF-8, or (ii) edit it to have the correct
charset= value in the tag.

Cheers!

 --
Mike Ford,  Electronic Information Services Adviser,
JG125, The Headingley Library,
James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 812 4730  Fax:  +44 113 812 3211


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

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



RE: [PHP] FRench characters not displayed correctly

2008-04-17 Thread Robert Cummings

On Thu, 2008-04-17 at 11:24 +0100, Ford, Mike wrote:
 On 17 April 2008 10:05, Robert Cummings advised:
 
  On Thu, 2008-04-17 at 10:57 +0200, Angelo Zanetti wrote:
  
  Thanks Robert,
  
  I have the following headers:
  
  
  http://fr..com/student/themes/english/locker_room/student.html
  
  GET /student/themes/english/locker_room/student.html? HTTP/1.1 Host:
  fr..com User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1;
 en-US;
  rv:1.8.1.14) Gecko/20080404 Firefox/2.0.0.14
  Accept:
  
  text/xml,application/xml,application/xhtml+xml,text/html;q=0.9
  ,text/plain;q=
  0.8,image/png,*/*;q=0.5
  Accept-Language: en-us,en;q=0.5
  Accept-Encoding: gzip,deflate
  Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
  Keep-Alive: 300
  Connection: keep-alive
  Referer:
  http://fr..com/student/themes/english/locker_room/student.html
  Cookie: PHPSESSID=818678404c170c8e4f5d237c1d0280a8
  If-Modified-Since: Sat, 17 Nov 2007 11:40:26 GMT
  If-None-Match: 6b97e-a9d-619b9e80
  Cache-Control: max-age=0
  
  HTTP/1.x 304 Not Modified
  Date: Thu, 17 Apr 2008 08:31:32 GMT
  Server: Apache/2.0.55 (Unix) PHP/5.1.2
  Connection: Keep-Alive
  Keep-Alive: timeout=15, max=200
  Etag: 6b97e-a9d-619b9e80
  -
  
  
  Now I see that the headers have:
  
  Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
  
  Which to me seems like it is sending both ISO-8859-1 and UTF-8?
  
  No, that's what kind of content the server is willing to accept from
  various sources such as POST.
 
 Er, no, that's what kind of content the browser is prepared to accept
 back from the server -- the headers starting from the GET line are what
 the browser sends to the server as part of the request.  The lines
 starting at the HTTP/1.x line are what the server returns.

Good catch, I must have crossed wires somewhere in my head and thought
about the accept-charset attribute for forms which *is* what the server
is willing to accept when processing the form.

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


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