php-general Digest 1 Jun 2006 01:19:59 -0000 Issue 4159

Topics (messages 237144 through 237174):

Re: $_FILES doesn't work but $_POST works
        237144 by: chris smith
        237145 by: Rabin Vincent

Re: corrupt pdfs
        237146 by: John Nichel
        237173 by: Richard Lynch
        237174 by: tedd

Re: Addtime is for 4.1, what can i use for 3.23? (pretty much 0T)
        237147 by: Ryan A

is there a faster "file" command?
        237148 by: Merlin
        237149 by: Brad Bonkoski
        237150 by: Dimiter Ivanov
        237152 by: Rory Browne
        237172 by: Richard Lynch

[PHP5] safe_mode_exec_dir
        237151 by: James Nunnerley
        237153 by: Jochem Maas

Session variables and words with spaces
        237154 by: Beauford
        237155 by: Brad Bonkoski
        237156 by: John Nichel
        237159 by: Beauford
        237160 by: Brad Bonkoski
        237161 by: cajbecu
        237162 by: Beauford
        237163 by: Beauford

ob_flush() problems
        237157 by: cajbecu
        237158 by: Brad Bonkoski
        237165 by: Adam Zey
        237170 by: Richard Lynch
        237171 by: Richard Lynch

Am I supposed to be using SPL?
        237164 by: D. Dante Lorenso
        237168 by: Jochem Maas

[ANNOUNCEMENT] Sparse 1.03b Released
        237166 by: Daniel Orner

»¥ÁªÍø×¢²á·þÎñƽ̨ÍƼöÈí¼þ
        237167 by: hmdr1

get directory paths recursively using SPL ... was Re: [PHP] Am I supposed to be 
using SPL?
        237169 by: D. Dante Lorenso

Administrivia:

To subscribe to the digest, e-mail:
        [EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
        [EMAIL PROTECTED]

To post to the list, e-mail:
        php-general@lists.php.net


----------------------------------------------------------------------
--- Begin Message ---
On 5/31/06, kartikay malhotra <[EMAIL PROTECTED]> wrote:
Thanks for your replies.

1. Did you put the enctype="multipart/form-data" into the FORM tag?
Ans: I do not have a form! I'm using a gateway utility to upload files

From documentation of Mbuni MMS gateway:

post-url
Response content is obtained as result of sending a HTTP POST request to the
provided URL. The POST message is *always* encoding (such as that used by a
web browser when an HTML form has the submitted using the
multipart/form-dataenctype=multipart/form-data parameter set). If
http-post-parameters field is given (see below), then the relevant
parameters are sent as part of the request. *X-Mbuni* headers are sent as
well.


http-post-parameters
Used in conjunction with post-url. Parameters are provided in the same way
as would be provided in an HTTP GET request (e.g. *
message=true&myname=test&image=%i*).

2.  Have you tried simply saving $_POST['userfile'] to a file?

     $save = $_POST['userfile'];
     $f=fopen($out,'a');
     copy($save, $out);

Files don't go into $_POST - they go into $_FILES.

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

--- End Message ---
--- Begin Message ---
On 5/31/06, chris smith <[EMAIL PROTECTED]> wrote:
On 5/31/06, kartikay malhotra <[EMAIL PROTECTED]> wrote:
> 2.  Have you tried simply saving $_POST['userfile'] to a file?
>
>      $save = $_POST['userfile'];
>      $f=fopen($out,'a');
>      copy($save, $out);

Files don't go into $_POST - they go into $_FILES.

Yes, his problem is that the $_FILES is not being set, but
there is some value in $_POST['userfile'].

Kartikay, I was suggesting that $_POST['userfile'] may
contain the file itself, not a filename. What does
$_POST['userfile'] contain? Try var_dump()ing it.

Rabin

--- End Message ---
--- Begin Message ---
Ross wrote:
I have pdfs saved as BLOBs I create the links dynamically but only some of the PDFs display an error message 'error opening this files...this file cannot be repaired..."


Is there a file size limit in kb for Blobs and what is it?
What size of file can a LONG BLOB accomodate?
If it is not this any ideas? It seems to fix it though!


Let's not even attempt to pretend that this question has anything remotely to do with PHP. mmmKay?

--
John C. Nichel IV
Programmer/System Admin (ÜberGeek)
Dot Com Holdings of Buffalo
716.856.9675
[EMAIL PROTECTED]

--- End Message ---
--- Begin Message ---
On Wed, May 31, 2006 3:56 am, Ross wrote:
> I have pdfs saved as BLOBs

We've been through this a zillion time, so search the archives for the
pros and cons.

> Is there a file size limit in kb for Blobs and what is it?

I believe it depends on compile-time settings, but this is really a
MySQL question...

It's probably 4 Meg or something.

> What size of file can a LONG BLOB accomodate?

Probably twice as much as a regular one.

> If it is not this any ideas? It seems to fix it though!

It will only fix it for PDFs up to the size of a LONG BLOB, whatever
that is.

The REAL fix, imho, is to stop abusing your database for large file
storage, and use the custom highly-optimized large file data storage
engine commonly known as the "file system"

-- 
Like Music?
http://l-i-e.com/artists.htm

--- End Message ---
--- Begin Message ---
At 6:26 PM -0500 5/31/06, Richard Lynch wrote:
>On Wed, May 31, 2006 3:56 am, Ross wrote:
>> I have pdfs saved as BLOBs
>
>We've been through this a zillion time, so search the archives for the
>pros and cons.
>
>> Is there a file size limit in kb for Blobs and what is it?
>
>I believe it depends on compile-time settings, but this is really a
>MySQL question...
>
>It's probably 4 Meg or something.
>
>> What size of file can a LONG BLOB accomodate?
>
>Probably twice as much as a regular one.
>
>> If it is not this any ideas? It seems to fix it though!
>
>It will only fix it for PDFs up to the size of a LONG BLOB, whatever
>that is.
>
>The REAL fix, imho, is to stop abusing your database for large file
>storage, and use the custom highly-optimized large file data storage
>engine commonly known as the "file system"

Yes, I was wondering that myself considering the onslaught of "no-no's" one 
gets by suggesting placing images into a dB. A PDf file is really not that much 
different and probably better served via file system.

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

--- End Message ---
--- Begin Message ---
Hey,

 
> Might be quicker for you to ask on a mysql mailing
> list :)

Yep, am waiting for the confirmation email...

 
> I tried a couple of different things looking at the
> mysql page 
>
(http://dev.mysql.com/doc/refman/4.1/en/date-and-time-functions.html)
> 
> but couldn't come up with a proper solution.


Yep, then tried some weird stuff and it worked :-)

INSERT INTO test2
VALUES (Curtime(), DATE_ADD(Now(), INTERVAL '5'
minute)); 


Maybe this will help someone else out. 

Thanks for trying though.

Cheers!
Ryan


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

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

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

I am reading a remote plain text file from another server via the file command:

$str = file ("http:/xxxxx");
This is a feed so there is no other way then reading it remote.

Now this reading takes up between 0.5 and 1.0 s which is far to slow. The whole other process on the site takes only 0.1 s and I would like to keep it inside this area of 0.1 - 0.2 s

Is there a faster way to read a remote txt file than with file() ?

If not, is there a way in php to process this in the background and continue to display the page without the results of the file?

Thank you in advance,

Merlin

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


Merlin wrote:

Hi there,

I am reading a remote plain text file from another server via the file command:

$str = file ("http:/xxxxx");
This is a feed so there is no other way then reading it remote.

Now this reading takes up between 0.5 and 1.0 s which is far to slow. The whole other process on the site takes only 0.1 s and I would like to keep it inside this area of 0.1 - 0.2 s

Is there a faster way to read a remote txt file than with file() ?

If not, is there a way in php to process this in the background and continue to display the page without the results of the file?

not sure on a "faster" way, but you can have PHP handle this on the backend without disrupting the normal page load time...
Enter AJAX...
Set a side a place on your page for the results, and on page load issue an AJAX request to a backend process to get your contents from the file, and when it is done, your page can display at that point in time. Fairly common usage for AJAX, so there should be some good tutorials out there which google will help you find.

-brad

Thank you in advance,

Merlin


--- End Message ---
--- Begin Message ---
On 5/31/06, Merlin <[EMAIL PROTECTED]> wrote:
Hi there,

I am reading a remote plain text file from another server via the file
command:

$str = file ("http:/xxxxx");
This is a feed so there is no other way then reading it remote.

Now this reading takes up between 0.5 and 1.0 s which is far to slow.
The whole other process on the site takes only 0.1 s and I would like to
keep it inside this area of 0.1 - 0.2 s

Is there a faster way to read a remote txt file than with file() ?

If not, is there a way in php to process this in the background and
continue to display the page without the results of the file?

Thank you in advance,

Merlin

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


It's said on the manual that
file_get_contents() is to be used if you want to read a text file.

from the manual :
"file_get_contents() is the preferred way to read the contents of a
file into a string. It will use memory mapping techniques if supported
by your OS to enhance performance."

The loading speed may be also affected by the time your server needs
to access the remote server.

If the information is not updated really fast, you may create a
cronjob to run every N minutes, and fetch that file on your server,
than make your site access the local version of the file, that will
effectively remove the network lag...

--- End Message ---
--- Begin Message ---
As I believe someone else said, file_get_contents() is the perfered way.

Bare in mind however that reading off a network will probably be slow
compared to other operations.

This of course depends on the speed of your network, and the complexity of
the other operations.

--- End Message ---
--- Begin Message ---
On Wed, May 31, 2006 9:19 am, Merlin wrote:
> I am reading a remote plain text file from another server via the file
> command:
>
> $str = file ("http:/xxxxx");
> This is a feed so there is no other way then reading it remote.
>
> Now this reading takes up between 0.5 and 1.0 s which is far to slow.
> The whole other process on the site takes only 0.1 s and I would like
> to
> keep it inside this area of 0.1 - 0.2 s

What, exactly, are you measuring on that "other side"?

Think carefully about this.

Because odds are really good that you ONLY measure the time for some
process to spit "out" the data.

Yet, there is a great deal more time being spent on the "other side"

For example, if this "other side" has PHP and Apache, and you ONLY
measure the PHP start/end times, you're ignoring any Apache overhead.

How fast/slow is, say, wget from the local server?
That's probably a much more accurate measure to compare your PHP
performance with.

> Is there a faster way to read a remote txt file than with file() ?

Since file() has to read each line and build up an array, it might be
slower than http://file_get_contents

> If not, is there a way in php to process this in the background and
> continue to display the page without the results of the file?

You can use asynchronous streams/sockets to get the process started at
the beginning of your script, do other stuff, and then get the results
at the end of your script.

You could also use something browser-side like XmlHttpRequest or
full-blown AJAX to have the browser download the feed "later" --
Though even a iframe could do that, much simpler, most likely.

I would not be too hasty jumping into the iframe/ajax/client-side
solution, personally, as it tends to open up cans of worms.

-- 
Like Music?
http://l-i-e.com/artists.htm

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

 

Should be a nice easy one - if running PHP5, how do I add more than one
exec_dir into the list?  i.e. what is the separator?

 

Cheers

Nunners


--- End Message ---
--- Begin Message ---
James Nunnerley wrote:
Hi Folks,

Should be a nice easy one - if running PHP5, how do I add more than one
exec_dir into the list?  i.e. what is the separator?

I have never used the directive but I imagine it hasn't changed between
php4 and php5 ...

and I would hazard a guess that the dir seperator is the same as for 
open_base_dir
name:

linux   = :
windows = ;




Cheers

Nunners



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

I have a form in which a drop down field is populated from a MySQL database.
I am also using sessions.

The problem is this. After I submit the form the session variable only shows
the part of the input before the space.

Example: if I choose Niagra Falls from the drop down list, then I only see
Niagra when I display it.

I'm not sure though if it is the session or the forms variable that is
causing the problem. I haven't been able to find much on this.

See code below....

Thanks



session_start(  );

......Open database and connect to server.......

Include("connect.inc");

!! Start of form !!

<select name="province">
<option selected>-- Select Province --</option>                  
                         
<?

$query = "select pid, location from province order by location"; $results =
mysql_query($query) or $mysqlerror = mysql_error(); if ($mysqlerror) { 
        $dberror = "Messed Up";
        include("index.php");
        exit;
        }       
                
while ($line = mysql_fetch_array($results)) {
        if($line['pid'] == 1) {
        echo "<Option
Value="$line['location'].">"$line['location']."</option>\n";
        }
}

</select>

!! Rest of Form !!

--- End Message ---
--- Begin Message --- Perhaps you should load up your initial form and then use the "view source" option in your browser as this will probably give you insight into your problems...
-Brad

Beauford wrote:

Hi,

I have a form in which a drop down field is populated from a MySQL database.
I am also using sessions.

The problem is this. After I submit the form the session variable only shows
the part of the input before the space.

Example: if I choose Niagra Falls from the drop down list, then I only see
Niagra when I display it.

I'm not sure though if it is the session or the forms variable that is
causing the problem. I haven't been able to find much on this.

See code below....

Thanks



session_start(  );

......Open database and connect to server.......

Include("connect.inc");

!! Start of form !!

<select name="province">
<option selected>-- Select Province --</option> <?

$query = "select pid, location from province order by location"; $results =
mysql_query($query) or $mysqlerror = mysql_error(); if ($mysqlerror) { $dberror = "Messed Up";
        include("index.php");
        exit;
        }       
                
while ($line = mysql_fetch_array($results)) {
        if($line['pid'] == 1) {
        echo "<Option
Value="$line['location'].">"$line['location']."</option>\n";
        }
}

</select>

!! Rest of Form !!


--- End Message ---
--- Begin Message ---
Beauford wrote:
Hi,

I have a form in which a drop down field is populated from a MySQL database.
I am also using sessions.

The problem is this. After I submit the form the session variable only shows
the part of the input before the space.

Example: if I choose Niagra Falls from the drop down list, then I only see
Niagra when I display it.

I'm not sure though if it is the session or the forms variable that is
causing the problem. I haven't been able to find much on this.

See code below....

Thanks



session_start(  );

......Open database and connect to server.......

Include("connect.inc");

!! Start of form !!

<select name="province">
<option selected>-- Select Province --</option> <?

$query = "select pid, location from province order by location"; $results =
mysql_query($query) or $mysqlerror = mysql_error(); if ($mysqlerror) { $dberror = "Messed Up";
        include("index.php");
        exit;
        }       
                
while ($line = mysql_fetch_array($results)) {
        if($line['pid'] == 1) {
        echo "<Option
Value="$line['location'].">"$line['location']."</option>\n";
        }
}

</select>


I'm surprised you're not getting a parse error...

echo "<Option Value='" . $line['location'] . "'>" . $line['location'] . "</option>\n";
--
John C. Nichel IV
Programmer/System Admin (ÜberGeek)
Dot Com Holdings of Buffalo
716.856.9675
[EMAIL PROTECTED]

--- End Message ---
--- Begin Message ---
 
Thanks - Done that though. It shows the way it should be.

Example: <option value=Niagara Falls>Niagara Falls</option>


-----Original Message-----
From: Brad Bonkoski [mailto:[EMAIL PROTECTED] 
Sent: May 31, 2006 2:28 PM
To: Beauford
Cc: php-general@lists.php.net
Subject: Re: [PHP] Session variables and words with spaces

Perhaps you should load up your initial form and then use the "view source"
option in your browser as this will probably give you insight into your
problems...
-Brad

Beauford wrote:

>Hi,
>
>I have a form in which a drop down field is populated from a MySQL
database.
>I am also using sessions.
>
>The problem is this. After I submit the form the session variable only 
>shows the part of the input before the space.
>
>Example: if I choose Niagra Falls from the drop down list, then I only 
>see Niagra when I display it.
>
>I'm not sure though if it is the session or the forms variable that is 
>causing the problem. I haven't been able to find much on this.
>
>See code below....
>
>Thanks
>
>
>
>session_start(  );
>
>......Open database and connect to server.......
>
>Include("connect.inc");
>
>!! Start of form !!
>
><select name="province">
><option selected>-- Select Province --</option>                         
>                        
><?
>
>$query = "select pid, location from province order by location"; 
>$results =
>mysql_query($query) or $mysqlerror = mysql_error(); if ($mysqlerror) { 
>       $dberror = "Messed Up";
>       include("index.php");
>       exit;
>       }       
>               
>while ($line = mysql_fetch_array($results)) {
>       if($line['pid'] == 1) {
>       echo "<Option
>Value="$line['location'].">"$line['location']."</option>\n";
>       }
>}
>
></select>
>
>!! Rest of Form !!
>
>  
>

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

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


Beauford wrote:


Thanks - Done that though. It shows the way it should be.

Example: <option value=Niagara Falls>Niagara Falls</option>


which of course is wrong.... and explains perfectly why you are getting the results you are getting...
it *should* display:
<option value="Niagra Falls">Niagra Falls</option>
(View source is a powerful tool!)
-Brad

-----Original Message-----
From: Brad Bonkoski [mailto:[EMAIL PROTECTED] Sent: May 31, 2006 2:28 PM
To: Beauford
Cc: php-general@lists.php.net
Subject: Re: [PHP] Session variables and words with spaces

Perhaps you should load up your initial form and then use the "view source"
option in your browser as this will probably give you insight into your
problems...
-Brad

Beauford wrote:

Hi,

I have a form in which a drop down field is populated from a MySQL
database.
I am also using sessions.

The problem is this. After I submit the form the session variable only shows the part of the input before the space.

Example: if I choose Niagra Falls from the drop down list, then I only see Niagra when I display it.

I'm not sure though if it is the session or the forms variable that is causing the problem. I haven't been able to find much on this.

See code below....

Thanks



session_start(  );

......Open database and connect to server.......

Include("connect.inc");

!! Start of form !!

<select name="province">
<option selected>-- Select Province --</option> <?

$query = "select pid, location from province order by location"; $results = mysql_query($query) or $mysqlerror = mysql_error(); if ($mysqlerror) { $dberror = "Messed Up";
        include("index.php");
        exit;
        }       
                
while ($line = mysql_fetch_array($results)) {
        if($line['pid'] == 1) {
        echo "<Option
Value="$line['location'].">"$line['location']."</option>\n";
        }
}

</select>

!! Rest of Form !!




--


--- End Message ---
--- Begin Message ---
<option value=Niagara Falls>Niagara Falls</option>

replace with

<option value="Niagara Falls">Niagara Falls</option> (note the quotes)

because you will post only "Niagara" instead "Niagara Falls"

cheers,

On 5/31/06, Beauford <[EMAIL PROTECTED]> wrote:

Thanks - Done that though. It shows the way it should be.

Example: <option value=Niagara Falls>Niagara Falls</option>


-----Original Message-----
From: Brad Bonkoski [mailto:[EMAIL PROTECTED]
Sent: May 31, 2006 2:28 PM
To: Beauford
Cc: php-general@lists.php.net
Subject: Re: [PHP] Session variables and words with spaces

Perhaps you should load up your initial form and then use the "view source"
option in your browser as this will probably give you insight into your
problems...
-Brad

Beauford wrote:

>Hi,
>
>I have a form in which a drop down field is populated from a MySQL
database.
>I am also using sessions.
>
>The problem is this. After I submit the form the session variable only
>shows the part of the input before the space.
>
>Example: if I choose Niagra Falls from the drop down list, then I only
>see Niagra when I display it.
>
>I'm not sure though if it is the session or the forms variable that is
>causing the problem. I haven't been able to find much on this.
>
>See code below....
>
>Thanks
>
>
>
>session_start(  );
>
>......Open database and connect to server.......
>
>Include("connect.inc");
>
>!! Start of form !!
>
><select name="province">
><option selected>-- Select Province --</option>
>
><?
>
>$query = "select pid, location from province order by location";
>$results =
>mysql_query($query) or $mysqlerror = mysql_error(); if ($mysqlerror) {
>       $dberror = "Messed Up";
>       include("index.php");
>       exit;
>       }
>
>while ($line = mysql_fetch_array($results)) {
>       if($line['pid'] == 1) {
>       echo "<Option
>Value="$line['location'].">"$line['location']."</option>\n";
>       }
>}
>
></select>
>
>!! Rest of Form !!
>
>
>

--
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



--- End Message ---
--- Begin Message ---
Not sure why I would get a parse error, but that did correct the problem. I
just completely missed the single quote. I never even clue'd in when I
looked at the source of the page.

Sometimes another pair of eyes does the trick. Maybe it's time for a break.

Thanks


>> I'm surprised you're not getting a parse error...

echo "<Option Value='" . $line['location'] . "'>" . $line['location'] . 
"</option>\n";
--
John C. Nichel IV
Programmer/System Admin (ÜberGeek)
Dot Com Holdings of Buffalo
716.856.9675
[EMAIL PROTECTED]

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

--- End Message ---
--- Begin Message ---
Yep, I see that now. I really need to take a break - been at this way to
long. 

Thanks to all. 

-----Original Message-----
From: Brad Bonkoski [mailto:[EMAIL PROTECTED] 
Sent: May 31, 2006 3:02 PM
To: Beauford
Cc: php-general@lists.php.net
Subject: Re: [PHP] Session variables and words with spaces



Beauford wrote:

> 
>Thanks - Done that though. It shows the way it should be.
>
>Example: <option value=Niagara Falls>Niagara Falls</option>
>
>
>  
>
which of course is wrong.... and explains perfectly why you are getting the
results you are getting...
it *should* display:
<option value="Niagra Falls">Niagra Falls</option> (View source is a
powerful tool!) -Brad

>-----Original Message-----
>From: Brad Bonkoski [mailto:[EMAIL PROTECTED]
>Sent: May 31, 2006 2:28 PM
>To: Beauford
>Cc: php-general@lists.php.net
>Subject: Re: [PHP] Session variables and words with spaces
>
>Perhaps you should load up your initial form and then use the "view source"
>option in your browser as this will probably give you insight into your 
>problems...
>-Brad
>
>Beauford wrote:
>
>  
>
>>Hi,
>>
>>I have a form in which a drop down field is populated from a MySQL
>>    
>>
>database.
>  
>
>>I am also using sessions.
>>
>>The problem is this. After I submit the form the session variable only 
>>shows the part of the input before the space.
>>
>>Example: if I choose Niagra Falls from the drop down list, then I only 
>>see Niagra when I display it.
>>
>>I'm not sure though if it is the session or the forms variable that is 
>>causing the problem. I haven't been able to find much on this.
>>
>>See code below....
>>
>>Thanks
>>
>>
>>
>>session_start(  );
>>
>>......Open database and connect to server.......
>>
>>Include("connect.inc");
>>
>>!! Start of form !!
>>
>><select name="province">
>><option selected>-- Select Province --</option>                        
>>                       
>><?
>>
>>$query = "select pid, location from province order by location"; 
>>$results =
>>mysql_query($query) or $mysqlerror = mysql_error(); if ($mysqlerror) { 
>>      $dberror = "Messed Up";
>>      include("index.php");
>>      exit;
>>      }       
>>              
>>while ($line = mysql_fetch_array($results)) {
>>      if($line['pid'] == 1) {
>>      echo "<Option
>>Value="$line['location'].">"$line['location']."</option>\n";
>>      }
>>}
>>
>></select>
>>
>>!! Rest of Form !!
>>
>> 
>>
>>    
>>
>
>--
>
>  
>

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

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

   for ($i=0; $i < 10; $i++) {
       $output = "ccc2";
       print "<pre>";
       echo $output;
       print "</pre>";
       ob_flush();
       flush();

       sleep(1);
   }

I want to show on the browser, "ccc2" (example) every 1 second, but it
shows all the text when the for stops... any ideea?

i tried all the examples from php.net, all the examples on the net,
bot no succes.

cheers,

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


cajbecu wrote:

Hello,

   for ($i=0; $i < 10; $i++) {
       $output = "ccc2";
       print "<pre>";
       echo $output;
       print "</pre>";
       ob_flush();
       flush();

       sleep(1);
   }

I want to show on the browser, "ccc2" (example) every 1 second, but it
shows all the text when the for stops... any ideea?

i tried all the examples from php.net, all the examples on the net,
bot no succes.

cheers,

PHP is a server side scripting language, so the information would not be sent to the browser( aka client) until the server side script has completed its execution.
-Brad

--- End Message ---
--- Begin Message ---
Brad Bonkoski wrote:


cajbecu wrote:

Hello,

   for ($i=0; $i < 10; $i++) {
       $output = "ccc2";
       print "<pre>";
       echo $output;
       print "</pre>";
       ob_flush();
       flush();

       sleep(1);
   }

I want to show on the browser, "ccc2" (example) every 1 second, but it
shows all the text when the for stops... any ideea?

i tried all the examples from php.net, all the examples on the net,
bot no succes.

cheers,

PHP is a server side scripting language, so the information would not be sent to the browser( aka client) until the server side script has completed its execution.
-Brad

That is incorrect. There is nothing stopping a PHP script from doing exactly what he says, and being a server-side script doesn't imply that the data will be buffered.

I suggest that both of you examine the contents of http://www.php.net/manual/en/function.flush.php for more information on obstacles to getting data to the client as it is generated.

As an unrelated note, there is no point in using "print" for some things and "echo" for others. For your uses, you might as well just use "echo" for everything.

Regards, Adam Zey.

--- End Message ---
--- Begin Message ---
On Wed, May 31, 2006 1:29 pm, cajbecu wrote:
>     for ($i=0; $i < 10; $i++) {
>         $output = "ccc2";
>         print "<pre>";
>         echo $output;
>         print "</pre>";
>         ob_flush();
>         flush();
>
>         sleep(1);
>     }
>
> I want to show on the browser, "ccc2" (example) every 1 second, but it
> shows all the text when the for stops... any ideea?
>
> i tried all the examples from php.net, all the examples on the net,
> bot no succes.

ob_flush() only makes sense if you have ob_start() somewhere, or if
output_buffering is enabled in php.ini

flush(); and sleep(1); are all you should need...

At least from PHP standpoint.

But there are many other players outside the control of PHP...

Apache could be buffering output.

TCP could be buffering output.

Your browser will NOT render some parts of some elements until the
tags are all closed -- If you are inside a TABLE, for instance, expect
not to see things happening in real-time.

-- 
Like Music?
http://l-i-e.com/artists.htm

--- End Message ---
--- Begin Message ---
On Wed, May 31, 2006 1:36 pm, Brad Bonkoski wrote:
> PHP is a server side scripting language, so the information would not
> be
> sent to the browser( aka client) until the server side script has
> completed its execution.

This is just plain incorrect.

While buffering within various pieces of software MAY alter the
timing, data IS output from PHP as it runs, not only after execution
is completed.

If you pump ENOUGH data out, and then sleep(10) and then pump ENOUGH
more data out, you WILL see the data in parallel with script
execution.

-- 
Like Music?
http://l-i-e.com/artists.htm

--- End Message ---
--- Begin Message --- I was about to write code to recursively list the contents of a directory when I remembered seeing an object in SPL that would do it for me:

http://us3.php.net/manual/en/function.recursivedirectoryiterator-next.php

But there is no documentation on this object, and although I have it in PHP 5.1.4, docs say it's might be only in CVS. So, I try using it and get this:

<?php
$dir = new RecursiveDirectoryIterator("/some/dir/path");
while($dir->valid()) {
   print $dir->current()."\n";
  $dir->next();
}
?>

But it doesn't seem to recurse through the directories. In fact, this acts just like DirectoryIterator. So, there must be a flag to make it recurse, but documentation is not there. I see this documentation here:

   http://www.php.net/~helly/php/ext/spl/

But that just looks like the source code was parsed to generate it, nothing much help in seeing an example of the usage.

Is SPL meant to be used? If so, is it experimental? Is it documented? Should I stay away from SPL for production code? What's the official word?

Dante

--- End Message ---
--- Begin Message ---
your not supposed to do anything ;-)
but you can if you like :-) ...

D. Dante Lorenso wrote:
> I was about to write code to recursively list the contents of a
> directory when I remembered seeing an object in SPL that would do it for
> me:
>
>
> http://us3.php.net/manual/en/function.recursivedirectoryiterator-next.php
>
> But there is no documentation on this object, and although I have it in
> PHP 5.1.4, docs say it's might be only in CVS.  So, I try using it and
> get this:
>
> <?php
> $dir = new RecursiveDirectoryIterator("/some/dir/path");
> while($dir->valid()) {
>    print $dir->current()."\n";

http://php.net/manual/en/function.recursivedirectoryiterator-haschildren.php

and related methods...

also take a look here:

http://www.wiki.cc/php/RecursiveDirectoryIterator

>   $dir->next();
> }
> ?>
>
> But it doesn't seem to recurse through the directories.  In fact, this
> acts just like DirectoryIterator.  So, there must be a flag to make it
> recurse, but documentation is not there.  I see this documentation here:
>
>    http://www.php.net/~helly/php/ext/spl/

try looking at the userland version of the SPL classes they give quite abit
away as to how they work and how you can use them.

>
> But that just looks like the source code was parsed to generate it,
> nothing much help in seeing an example of the usage.
>
> Is SPL meant to be used?  If so, is it experimental?  Is it documented?
> Should I stay away from SPL for production code?  What's the official word?

yes it's meant to be used, yes you can use it in production BUT your
a little on the bleeding edge (not very many people using it full on) AND
the whole of SPL is still a little in flex (as is php5->php6 in general) so
that you may be forced, occasionally, to adapt your code to changes (e.g.
constants that were formally used in SPL are now class constants.)

and please note this is not the official word but jmho.

>
> Dante
>

--- End Message ---
--- Begin Message --- New beta release of Sparse, my framework for writing MySQL-based programs without any code. This release includes search capability and completely removes all external dependencies (also allowing for Sparse tags to be embedded in regular tags).
        Try it out!
http://sparse-php.sourceforge.net/

--Daniel
--
Sparse - a new way to write MySQL-based programs with little to no actual programming. Save yourself time and effort!
http://sparse-php.sourceforge.net/

--- End Message ---
--- Begin Message ---
您好:

[EMAIL PROTECTED]

互联网共享软件注册服务平台向您推荐以下软件:

http://www.phy0032.com

1.企业名录搜索王

功能:可按行业、地区、关键词等不同要求精确搜集企业名称、联系人、
地址、电话、手机、传真、网址、EMAIL、企业简介等,并进行整理,形成客
户资源。

网络已经成为企业推广产品、提高知名度的必要的手段,企业
将自己的公司信息在BtoB网站上进行登录成为很多企业上网之后必做的事情;
同时,比较有名气的网站为了充实自己的数据资源,也不断的查找这样的企业
客户群以不断的提高自己的知名度。因此,如果能够将网络上这些网站上的企
业名录信息动态(所谓动态是指想什么时候搜索就什么时候搜索)的搜索下来,
那将是最新的、最具潜力的、最宝贵的客户资源。

免费下载:http://www.phy0032.com/yx/qysetup.exe

2.网络营销大师

功能:自动为企业发布产品信息的软件。网上信息发布是企业在网上进行宣传的重要手段,本软件集多功能于一体,价格低,适合中小企业和个人购买,但功能比起网上其他同类产品更加强大。

免费下载:http://www.phy0032.com/yx/setup.exe

咨询:0763-3994117 
Q  Q:88636609
网址:http://www.phy0032.com


--- End Message ---
--- Begin Message ---
Jochem Maas wrote:
also take a look here:
http://www.wiki.cc/php/RecursiveDirectoryIterator

yes it's meant to be used, yes you can use it in production BUT your
a little on the bleeding edge (not very many people using it full on) AND
the whole of SPL is still a little in flex (as is php5->php6 in general) so
that you may be forced, occasionally, to adapt your code to changes (e.g.
constants that were formally used in SPL are now class constants.)

Wow, this is some magical stuff.  Here is my function in case it's of use:

   //----------------------------------------------------------------------
   /**
    * Magical SPL code to recursively list files in a directory
    */
   public static function get_paths_recursive($start_path) {
       $paths = array();
       $rdi = new RecursiveDirectoryIterator($start_path);
       foreach (new RecursiveIteratorIterator($rdi) as $path) {
           array_push($paths, (string) $path);
       }
       return $paths;
   }

   //----------------------------------------------------------------------

This iterates over objects like arrays, casts objects as strings, and iterates iterators. All sorts of fun and joy enough to make your head spin. Seems to
work, though ;-)

Thanks for the wiki doc link, Jochem.

Dante

--- End Message ---

Reply via email to