Re: [PHP] Re: about php comet

2011-06-03 Thread Adam Richardson
On Fri, Jun 3, 2011 at 1:50 AM, 李白|字一日 calid...@gmail.com wrote:

 any idea?

 2011/5/25 李白|字一日 calid...@gmail.com

  hello,
 
  I am every interested in comet applications recently, and sadly found php
  is very weak in this area.
 
  i am just wondering if it is possible to write an extension to extend the
  ability of the php to easy the way to comet applications?
 
  if it possible for php to hold the connect from the client when it is in
  fast cgi mode or apache mod php mode?


Comet can use one of several techniques for low-latency data (
http://cometdaily.com/about/), with the long-polling mechanism to simulate
the realtime pushing of data from the server being a popular option:
http://cometdaily.com/2007/11/15/the-long-polling-technique/
http://en.wikipedia.org/wiki/Comet_(programming)

http://en.wikipedia.org/wiki/Comet_(programming)To my understanding, PHP
itself can accommodate this quite nicely. Merely start an infinite loop that
breaks and returns new data when available. You'll probably have to adjust
your web server settings and php.ini configuration to allow reasonably long
requests for this particular need. However, when requests do time out, it's
not a big deal as the javascript should be set up to reinitiate a new
request if that happens, just as it would if the request returned new data
and closed, giving the appearance of a continuous stream of pushed data.

This all said, if you wanted to write an extension to facilitate long
polling, you could, but given the natural latencies for these requests, I'm
not sure you'd find a significant benefit.

Adam

-- 
Nephtali:  A simple, flexible, fast, and security-focused PHP framework
http://nephtaliproject.com


Re: [PHP] Re: about php comet

2011-06-03 Thread 李白|字一日
is there an efficient way to hold the requests while loop is an expensive
way in most cases.

and i don't know how to notify the holding connections if the change need to
be notify to the holding requests?

writing extension to php is also a very expensive way for me:(

2011/6/3 Adam Richardson simples...@gmail.com

 On Fri, Jun 3, 2011 at 1:50 AM, 李白|字一日 calid...@gmail.com wrote:

 any idea?

 2011/5/25 李白|字一日 calid...@gmail.com

  hello,
 
  I am every interested in comet applications recently, and sadly found
 php
  is very weak in this area.
 
  i am just wondering if it is possible to write an extension to extend
 the
  ability of the php to easy the way to comet applications?
 
  if it possible for php to hold the connect from the client when it is in
  fast cgi mode or apache mod php mode?


 Comet can use one of several techniques for low-latency data (
 http://cometdaily.com/about/), with the long-polling mechanism to simulate
 the realtime pushing of data from the server being a popular option:
 http://cometdaily.com/2007/11/15/the-long-polling-technique/
 http://en.wikipedia.org/wiki/Comet_(programming)

 http://en.wikipedia.org/wiki/Comet_(programming)To my understanding, PHP
 itself can accommodate this quite nicely. Merely start an infinite loop that
 breaks and returns new data when available. You'll probably have to adjust
 your web server settings and php.ini configuration to allow reasonably long
 requests for this particular need. However, when requests do time out, it's
 not a big deal as the javascript should be set up to reinitiate a new
 request if that happens, just as it would if the request returned new data
 and closed, giving the appearance of a continuous stream of pushed data.

 This all said, if you wanted to write an extension to facilitate long
 polling, you could, but given the natural latencies for these requests, I'm
 not sure you'd find a significant benefit.

 Adam

 --
 Nephtali:  A simple, flexible, fast, and security-focused PHP framework
 http://nephtaliproject.com



Re: [PHP] Re: about php comet

2011-06-03 Thread Adam Richardson
On Fri, Jun 3, 2011 at 2:20 AM, 李白|字一日 calid...@gmail.com wrote:

 is there an efficient way to hold the requests while loop is an expensive
 way in most cases.


You can call sleep(number_of_seconds_to_sleep) within the while loop to
lower the cost, so to speak.


 and i don't know how to notify the holding connections if the change need
 to be notify to the holding requests?


Sorry, I'm not sure what you mean here.

Let's say you were checking a db table for new rows. When a new row
appeared, you'd break out of the loop and return the data to the page with
the javascript that initiated the request (maybe you're PHP is returning
JSON, XML, or an HTML fragment for the javascript to manipulate.) The
javascript would update the page content and then initiate a new
long-polling request and wait for new data.

writing extension to php is also a very expensive way for me:(


I agree with you. That's in part why I suggested that the extension wouldn't
be needed or worthwhile in this case and basic PHP would be a reasonable
solution.

-- 
Nephtali:  A simple, flexible, fast, and security-focused PHP framework
http://nephtaliproject.com


Re: [PHP] Re: about php comet

2011-06-03 Thread Adam Richardson
On Fri, Jun 3, 2011 at 3:43 AM, 李白|字一日 calid...@gmail.com wrote:



 2011/6/3 Adam Richardson simples...@gmail.com

 On Fri, Jun 3, 2011 at 2:20 AM, 李白|字一日 calid...@gmail.com wrote:

 is there an efficient way to hold the requests while loop is an expensive
 way in most cases.


 You can call sleep(number_of_seconds_to_sleep) within the while loop to
 lower the cost, so to speak.

 yes, an interrupt will be a better way. currently libevent is in beta
 state, and i don't know if the libevent extension can be used in mod_php to
 implement comet applications.


Oh, I see. Yes, I'm not sure I'd try using that extension yet.




 and i don't know how to notify the holding connections if the change need
 to be notify to the holding requests?


 Sorry, I'm not sure what you mean here.


 please forgive my poor english, i mean we may have projects need
 interaction with mulitple users and the state changes of one user should be
 send to the users involved, like online games chatting rooms.


I believe I understand you, now. This could get costly in terms of
resources, and I now better understand your interest in the libevent
extension.

I'd be tempted to write custom C extensions for a web server like nginx,
which naturally handles asynchronous IO. And, in this case, you could even
make use of fast polling instead of long polling, due to the performance of
nginx, such as demonstrated in the this example:
http://amix.dk/blog/post/19414

And, don't worry about your English too much. My Chinese stops after ni hao
;)

Adam

-- 
Nephtali:  A simple, flexible, fast, and security-focused PHP framework
http://nephtaliproject.com


Re: [PHP] Re: about php comet

2011-06-03 Thread Stuart Dallas
On Fri, Jun 3, 2011 at 7:11 AM, Adam Richardson simples...@gmail.comwrote:

 On Fri, Jun 3, 2011 at 1:50 AM, 李白|字一日 calid...@gmail.com wrote:

  any idea?
 
  2011/5/25 李白|字一日 calid...@gmail.com
 
   hello,
  
   I am every interested in comet applications recently, and sadly found
 php
   is very weak in this area.
  
   i am just wondering if it is possible to write an extension to extend
 the
   ability of the php to easy the way to comet applications?
  
   if it possible for php to hold the connect from the client when it is
 in
   fast cgi mode or apache mod php mode?
 

 Comet can use one of several techniques for low-latency data (
 http://cometdaily.com/about/), with the long-polling mechanism to simulate
 the realtime pushing of data from the server being a popular option:
 http://cometdaily.com/2007/11/15/the-long-polling-technique/
 http://en.wikipedia.org/wiki/Comet_(programming)

 http://en.wikipedia.org/wiki/Comet_(programming)To my understanding, PHP
 itself can accommodate this quite nicely. Merely start an infinite loop
 that
 breaks and returns new data when available. You'll probably have to adjust
 your web server settings and php.ini configuration to allow reasonably long
 requests for this particular need. However, when requests do time out, it's
 not a big deal as the javascript should be set up to reinitiate a new
 request if that happens, just as it would if the request returned new data
 and closed, giving the appearance of a continuous stream of pushed data.

 This all said, if you wanted to write an extension to facilitate long
 polling, you could, but given the natural latencies for these requests, I'm
 not sure you'd find a significant benefit.


One word of caution... While PHP can be used to implement long polling, bear
in mind that PHP is fairly expensive in terms of resource usage per
connection. Unless you're swimming in servers or only expecting a few
concurrent connections at any one time, I'd recommend using something that
holds multiple connections per process, rather than one process per
connection.

IMO, web-based PHP is not the right solution to this problem. You could
write a select-based comet server in PHP, but it definitely wouldn't be in
my top 10 language choices.

I've just seen a later email in this thread that mentions that this is a
chat-type system. Watch this and have your mind blown...
http://vimeo.com/20605470 - at some point he describes how to write a pretty
efficient chat server in PHP using ZeroMQ, but the whole thing is worth
watching.

-Stuart

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


Re: [PHP] Re: about php comet

2011-06-03 Thread 李白|字一日
2011/6/3 Adam Richardson simples...@gmail.com

 On Fri, Jun 3, 2011 at 3:43 AM, 李白|字一日 calid...@gmail.com wrote:



 2011/6/3 Adam Richardson simples...@gmail.com

 On Fri, Jun 3, 2011 at 2:20 AM, 李白|字一日 calid...@gmail.com wrote:

 is there an efficient way to hold the requests while loop is an
 expensive way in most cases.


 You can call sleep(number_of_seconds_to_sleep) within the while loop to
 lower the cost, so to speak.

 yes, an interrupt will be a better way. currently libevent is in beta
 state, and i don't know if the libevent extension can be used in mod_php to
 implement comet applications.


 Oh, I see. Yes, I'm not sure I'd try using that extension yet.




 and i don't know how to notify the holding connections if the change
 need to be notify to the holding requests?


 Sorry, I'm not sure what you mean here.


 please forgive my poor english, i mean we may have projects need
 interaction with mulitple users and the state changes of one user should be
 send to the users involved, like online games chatting rooms.


 I believe I understand you, now. This could get costly in terms of
 resources, and I now better understand your interest in the libevent
 extension.

 I'd be tempted to write custom C extensions for a web server like nginx,
 which naturally handles asynchronous IO. And, in this case, you could even
 make use of fast polling instead of long polling, due to the performance of
 nginx, such as demonstrated in the this example:
 http://amix.dk/blog/post/19414


thanks for the advice,
but i don't know if it can be integrated into web pages.
where in web pages,
browsers will stop the requests to different ports even when the url having
the save domain name.

if i want to host more pages, add more interactions, it would be every
difficult.

so it would be better to have php solutions to make it easier :)



 And, don't worry about your English too much. My Chinese stops after ni hao
 ;)


ni hao is a good start:)


 Adam

 --
 Nephtali:  A simple, flexible, fast, and security-focused PHP framework
 http://nephtaliproject.com



[PHP] Re: about php comet

2011-06-02 Thread 李白|字一日
any idea?

2011/5/25 李白|字一日 calid...@gmail.com

 hello,

 I am every interested in comet applications recently, and sadly found php
 is very weak in this area.

 i am just wondering if it is possible to write an extension to extend the
 ability of the php to easy the way to comet applications?

 if it possible for php to hold the connect from the client when it is in
 fast cgi mode or apache mod php mode?

 thanks.




[PHP] Re: About PHP/MYSQL Pagination

2007-08-02 Thread Kelvin Park

Kelvin Park wrote:
I just couldn't find it anywhere, google or yahoo. I know how to make 
first, previous, last, and next links for php/mysql pagination. How do 
you list page numbers in the middle, between previous and next? (ex. 
 first previous | 1 2 3 4 5 | next last  )


I know how to display them from 1 to whatever by using for loop, but 
the problem comes in when I click next from page 5, it does not 
get re-listed starting from page 6.



nevermind, I figured it out. didn't know it was quite easy

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



Re: [PHP] Re: About PHP/XML/XSLT/MYSQL Web Sites

2007-07-13 Thread Nathan Nobbe

Although it is necessary to convert SQL data into XML before it can be
processed in an XSL transformation, it is a waste of time converting user
input into XML before it is added to the database as none of the
SELECT/INSERT/UPDATE/DELETE commands can work with XML files. It is far
easier to take the GET/POST array and convert it into an sql query

directly

without any intermediate XML.


This is what i have been trying to express to OP.  Also, i havent had time
to
fully explore your application framework, but i have had a glimpse at it.  i
really appreciate your explanation of modularizing the xsl templates as i
was
struggling to grasp this with my limited exposure to xsl.
i read up about you on your site and discovered you had been using xsl prior
to php.  i am the reverse of that, so while ive been using php for a few
years
now xsl is still very new to me.
your documentation and articles are quite excellent.  i hope you dont mind
if i
ask a couple questions in the future myself :)

-nathan

On 7/13/07, Tony Marston [EMAIL PROTECTED] wrote:


Although it is necessary to convert SQL data into XML before it can be
processed in an XSL transformation, it is a waste of time converting user
input into XML before it is added to the database as none of the
SELECT/INSERT/UPDATE/DELETE commands can work with XML files. It is far
easier to take the GET/POST array and convert it into an sql query
directly
without any intermediate XML.

FYI a complete framework which creates all HTML using XML+XSL has already
been built, and is described at
http://www.tonymarston.net/php-mysql/infrastructure.html#figure5, with a
working sample application which is described in and can be downloaded
from
http://www.tonymarston.net/php-mysql/sample-application.html

--
Tony Marston
http://www.tonymarston.net
http://www.radicore.org

Kelvin Park [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 I'm trying to setup a XSLT based web site.
 I wasn't exactly sure about the flow of the whole system when data from
 relational database is transferred to XML and in turn the data inputted
 from the user is relayed back to the database through XML (or directly
 to the database with PHP DB connection). I built a flowchart
 illustrating what the flow of the XSLT/PHP/MYSQL system might be like.
 If you think it's the wrong way or an inefficient way of getting user
 inputted data back to mysql, I would appreciate any comments.
 If you cannot download the PDF file, you can bring it up with direct
 address the the file: http://www.envigan.net/CMSFLOW.pdf



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




[PHP] Re: About PHP/XML/XSLT/MYSQL Web Sites

2007-07-13 Thread Tony Marston
Although it is necessary to convert SQL data into XML before it can be 
processed in an XSL transformation, it is a waste of time converting user 
input into XML before it is added to the database as none of the 
SELECT/INSERT/UPDATE/DELETE commands can work with XML files. It is far 
easier to take the GET/POST array and convert it into an sql query directly 
without any intermediate XML.

FYI a complete framework which creates all HTML using XML+XSL has already 
been built, and is described at 
http://www.tonymarston.net/php-mysql/infrastructure.html#figure5, with a 
working sample application which is described in and can be downloaded from 
http://www.tonymarston.net/php-mysql/sample-application.html

-- 
Tony Marston
http://www.tonymarston.net
http://www.radicore.org

Kelvin Park [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 I'm trying to setup a XSLT based web site.
 I wasn't exactly sure about the flow of the whole system when data from
 relational database is transferred to XML and in turn the data inputted
 from the user is relayed back to the database through XML (or directly
 to the database with PHP DB connection). I built a flowchart
 illustrating what the flow of the XSLT/PHP/MYSQL system might be like.
 If you think it's the wrong way or an inefficient way of getting user
 inputted data back to mysql, I would appreciate any comments.
 If you cannot download the PDF file, you can bring it up with direct
 address the the file: http://www.envigan.net/CMSFLOW.pdf

 

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



Re: [PHP] Re: about PHP

2005-09-20 Thread viraj
On 9/20/05, Srinivasan Kumar [EMAIL PROTECTED] wrote:
 hello sir,
 I am srinivasan,I am a web designer.I hered about PHP
 is the safest pages while using monetory
 transaction,

mmm! nop, PHP is not providing anything to secure your transactions
otherthan few fuctions to handle your login sessions and support on
few data encryption functions. but you can develop a good web
application/website using PHP.

 so i want to learn about the PHP. so only
 I need to view or run the PHP Pages in my local server

PHP is a server side scripting language, to use php for your website,
you have to install php on your webserver and configure PWS to handle
php pages. for this you need to read some manuals and spent some time
on research and development work.

i recomend you to read a lttle and slowly start PHPing.

http://forums.devarticles.com/archive/t-2574/Article-Discussion-Installing-PHP-Under-Personal-Web-Server


~viraj.

 (i.e.PWS) so only i am asking how to view the PHP
 pages in my local server (i.e.PWS)as a asp page
 
 thanking you for your kindly reply
 K.Srinivasan
 
 --- viraj [EMAIL PROTECTED] wrote:
 
  On 9/20/05, Srinivasan Kumar
  [EMAIL PROTECTED] wrote:
   sir,
this is srinivasan i have to know about the
  php.i.e.
 
  Google is your friend! ..the best is to search/read
  a bit more about
  PHP. follow these links..
 
  http://www.php.net/tut.php
 
 http://www.google.com/search?hl=enlr=oi=defmoreq=define:PHP
 
how can i view the php pages in windows98
  PWS?.could
 
  please be specific. write a little more, explaining
  what you want to
  do with php and your current knowledge in
  programming. so the others
  on the list can help you better to solve your issue.
 
 
  ~viraj.
 
you reply in this regard.
thanking you
k.srinivasan
  
  
   Gabor Hojtsy [EMAIL PROTECTED] wrote:Dear
  Srinivasan Kumar,
  
   Since your problem has nothing to do with
   webmastering of the php.net website, it does
   not belong in here Please contact
   php-general@lists.php.net (a mailing list)
   with support questions or see
  http://php.net/support
   for more support options.
 
 
 
 __
 Do You Yahoo!?
 Tired of spam?  Yahoo! Mail has the best spam protection around
 http://mail.yahoo.com


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



[PHP] Re: about PHP

2005-09-19 Thread Srinivasan Kumar
sir,
 this is srinivasan i have to know about the php.i.e.
 how can i view the php pages in windows98 PWS?.could
 you reply in this regard.
 thanking you
 k.srinivasan


Gabor Hojtsy [EMAIL PROTECTED] wrote:Dear Srinivasan Kumar,

Since your problem has nothing to do with
webmastering of the php.net website, it does
not belong in here Please contact
php-general@lists.php.net (a mailing list)
with support questions or see http://php.net/support
for more support options.

Regards,
Gabor Hojtsy

Srinivasan Kumar wrote:
 sir,
 this is srinivasan i have to know about the php.i.e.
 how can i view the php pages in windows98 PWS?.could
 you reply in this regard.
 thanking you
 k.srinivasan
 
 
 
 __ 
 Yahoo! Mail - PC Magazine Editors' Choice 2005 
 http://mail.yahoo.com
 




-
Yahoo! for Good
 Click here to donate to the Hurricane Katrina relief effort. 

Re: [PHP] Re: about PHP

2005-09-19 Thread viraj
On 9/20/05, Srinivasan Kumar [EMAIL PROTECTED] wrote:
 sir,
  this is srinivasan i have to know about the php.i.e.

Google is your friend! ..the best is to search/read a bit more about
PHP. follow these links..

http://www.php.net/tut.php
http://www.google.com/search?hl=enlr=oi=defmoreq=define:PHP

  how can i view the php pages in windows98 PWS?.could

please be specific. write a little more, explaining what you want to
do with php and your current knowledge in programming. so the others
on the list can help you better to solve your issue.


~viraj.

  you reply in this regard.
  thanking you
  k.srinivasan
 
 
 Gabor Hojtsy [EMAIL PROTECTED] wrote:Dear Srinivasan Kumar,
 
 Since your problem has nothing to do with
 webmastering of the php.net website, it does
 not belong in here Please contact
 php-general@lists.php.net (a mailing list)
 with support questions or see http://php.net/support
 for more support options.

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



[PHP] Re: About php and mysql

2004-02-24 Thread Jakes
mysql_connect(IP, username, password);


[EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED]
 Hello,

 I want to know how to control php program connect to MySQL Database
 System ( another computer machine ) ?

 Thank a lots.

 Ed.



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



[PHP] Re: ? about PHP includes

2001-08-03 Thread Richard Lynch

 I just discovered PHP this week. I'm reading about include statements. If
I
 have a text file 2000 characters in length that I want to include, I would
 do this to include to whole file:

 ?php
 include (file.txt);
 ?

http://php.net/fopen
http://php.net/fread

?php
$path = file.txt;
$file = fopen($path, 'r') or die(Could not open $path.  Try full path
or something.);
$data = fread($file, 250);
echo $data;
?

Note that include not only includes a text file, but also executes any ?php
? tags within it.

So it's not ideal for sucking in a whole plain text file anyway.

Check out http://php.net/readfile

--
WARNING [EMAIL PROTECTED] address is an endangered species -- Use
[EMAIL PROTECTED]
Wanna help me out?  Like Music?  Buy a CD: http://l-i-e.com/artists.htm
Volunteer a little time: http://chatmusic.com/volunteer.htm



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]