Flint Million | 1 Jul 01:31 2009
Picon

check a variable after EACH function

This might seem silly but here's what I'm trying to do

Suppose I have some kind of check variable - say for example
$abort_now. Or it could be a function. Something to be evaluated to a
value.

I want to execute a block of statements, but after EACH statement
executes, check the value of $abort_now and if it is true, break; out
of the block.

Here's an example

do {
  do_something();
  do_something_else();
  do_another_thing();
  do_yet_another_thing();
  and_keep_doing_things();
} while ($abort_now != 1);

What I want to happen is for each statement to execute, and keep
looping around, until the $abort_now variable is set to 1. Now,
suppose any one of the statements in that block may cause $abort_now
to become 1. If that happens, I want the block to stop executing
immediately and not continue executing further statements.

For example, do_another_thing() causes $abort_now to equal 1. I do not
want do_yet_another_thing or keep doing things to execute. I want the
loop to stop right there.

(Continue reading)

Shawn McKenzie | 1 Jul 01:56 2009
Picon

Re: check a variable after EACH function

Flint Million wrote:
> This might seem silly but here's what I'm trying to do
> 
> Suppose I have some kind of check variable - say for example
> $abort_now. Or it could be a function. Something to be evaluated to a
> value.
> 
> I want to execute a block of statements, but after EACH statement
> executes, check the value of $abort_now and if it is true, break; out
> of the block.
> 
> Here's an example
> 
> do {
>   do_something();
>   do_something_else();
>   do_another_thing();
>   do_yet_another_thing();
>   and_keep_doing_things();
> } while ($abort_now != 1);
> 
> What I want to happen is for each statement to execute, and keep
> looping around, until the $abort_now variable is set to 1. Now,
> suppose any one of the statements in that block may cause $abort_now
> to become 1. If that happens, I want the block to stop executing
> immediately and not continue executing further statements.
> 
> For example, do_another_thing() causes $abort_now to equal 1. I do not
> want do_yet_another_thing or keep doing things to execute. I want the
> loop to stop right there.
(Continue reading)

Michael A. Peters | 1 Jul 01:57 2009
Picon

Re: Best way to reinstate radio-button states from database?

Tom Worster wrote:
*snip*
> 
> michael: radios and checkboxes take the checked attribute -- options in
> selects take the selected attribute.

Doh - I knew that.
Typo. I always thought it silly there were two different attributes 
anyway, when they basically are same thing and can never both occur in 
same tag.

--

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

PJ | 1 Jul 02:06 2009
Picon

Re: exasperated again - shot in the foot

Jay Blanchard wrote:
> [snip]
> Use the OOP interface to mysqli or PDO and these problems don't happen
> [/snip]
>
> Either that or include a modicum of error checking in your code. 
>
>   
OK, Ok, I feel stupid enough already.
I'm not sure I want to get in that deep... it's tough enough with the
simple stuff...
so, talk to me about the OOP interface or the PDO... :-\

-- 
Hervé Kempf: "Pour sauver la planète, sortez du capitalisme."
-------------------------------------------------------------
Phil Jourdan --- pj <at> ptahhotep.com
   http://www.ptahhotep.com
   http://www.chiccantine.com/andypantry.php

--

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

Mary Anderson | 1 Jul 03:38 2009
Picon

Cleaning up automatically when leaving a page

Hi all,

   I have a php application for which I have a page which creates 
temporary junk and puts it into a persistent store  (in this case a 
postgres database, but that is beside the point.)

   I have a Save button which puts the stuff I really want into the 
persistent store and cleans up the temporary junk.  I have a Cancel 
button which only cleans up the temporary junk.

    I would really like to have the cleanup code run anytime a user 
leaves the page without hitting the Save button.  Is there anyway to do 
this?  I.e. have php code called conditionally on exiting the page?

Thanks
Mary

--

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

Michael A. Peters | 1 Jul 04:02 2009
Picon

Re: Cleaning up automatically when leaving a page

Mary Anderson wrote:
> Hi all,
> 
>   I have a php application for which I have a page which creates 
> temporary junk and puts it into a persistent store  (in this case a 
> postgres database, but that is beside the point.)
> 
>   I have a Save button which puts the stuff I really want into the 
> persistent store and cleans up the temporary junk.  I have a Cancel 
> button which only cleans up the temporary junk.
> 
>    I would really like to have the cleanup code run anytime a user 
> leaves the page without hitting the Save button.  Is there anyway to do 
> this?  I.e. have php code called conditionally on exiting the page?
> 
> Thanks
> Mary
> 

I do a similar thing and put a unix timestamp on the temporary database.
A cron job run once a day calls a page that deletes anything in the 
temporary database that has a timestamp > 24 hours old.

You don't have to do it with a cron job - you can also have the function 
that writes to the table delete anything older than X hours if you don't 
have facilities to cron (though you can run the cron job from any 
machine, doesn't need to run on the server)

something like this

(Continue reading)

Paul M Foster | 1 Jul 04:48 2009

Re: check a variable after EACH function

On Tue, Jun 30, 2009 at 06:31:54PM -0500, Flint Million wrote:

> This might seem silly but here's what I'm trying to do
> 
> Suppose I have some kind of check variable - say for example
> $abort_now. Or it could be a function. Something to be evaluated to a
> value.
> 
> I want to execute a block of statements, but after EACH statement
> executes, check the value of $abort_now and if it is true, break; out
> of the block.
> 
> Here's an example
> 
> do {
>   do_something();
>   do_something_else();
>   do_another_thing();
>   do_yet_another_thing();
>   and_keep_doing_things();
> } while ($abort_now != 1);
> 
> What I want to happen is for each statement to execute, and keep
> looping around, until the $abort_now variable is set to 1. Now,
> suppose any one of the statements in that block may cause $abort_now
> to become 1. If that happens, I want the block to stop executing
> immediately and not continue executing further statements.
> 
> For example, do_another_thing() causes $abort_now to equal 1. I do not
> want do_yet_another_thing or keep doing things to execute. I want the
(Continue reading)

Paul M Foster | 1 Jul 04:59 2009

Re: Cleaning up automatically when leaving a page

On Tue, Jun 30, 2009 at 06:38:19PM -0700, Mary Anderson wrote:

> Hi all,
>
>   I have a php application for which I have a page which creates
> temporary junk and puts it into a persistent store  (in this case a
> postgres database, but that is beside the point.)
>
>   I have a Save button which puts the stuff I really want into the
> persistent store and cleans up the temporary junk.  I have a Cancel
> button which only cleans up the temporary junk.
>
>    I would really like to have the cleanup code run anytime a user
> leaves the page without hitting the Save button.  Is there anyway to do
> this?  I.e. have php code called conditionally on exiting the page?

If the user hits the "Back" button or exits via clicking on some link on
the page, there's no reasonable way to do this (Michael's cron versions
excepted). Because the HTTP protocol has no effective memory, there's no
way for it to know that the user exited without saving. You can do
various tricky things like set a $_SESSION variable, and then have it
checked at the top of each page where the user could go, and check and
clean up if the variable has a certain value. But that's pretty tedious.
You could execute the whole thing as part of a class, and put a check in
the constructor of the class (where it will be called on every page)
which cleans up if necessary.

In other words, there are ways to do this, but they are tedious. The
PHP/HTTP execution engines have no way of doing it on their own.

(Continue reading)

Louie Miranda | 1 Jul 05:19 2009
Picon

Re: Re: Push an Array, Comma separated.

This is what I did. And it worked.

$saveFiles = array();
$arrSize=sizeof($saveFiles);
            for ($number = 0; $number < $arrSize; $number++) {
                $saveFilesDump = "$saveFiles[$number], ";
                echo "$saveFiles[$number], ";
            }

File1.txt, File2.txt, File3.txt,

--
Louie Miranda (lmiranda <at> gmail.com)
http://www.louiemiranda.net

Quality Web Hosting - www.axishift.com
Pinoy Web Hosting, Web Hosting Philippines

2009/6/30 João Cândido de Souza Neto <joao <at> consultorweb.cnt.br>

> May be array_merge($array, explode(",", $string)).
>
> --
> João Cândido de Souza Neto
> SIENS SOLUÇÕES EM GESTÃO DE NEGÓCIOS
> Fone: (0XX41) 3033-3636 - JS
> www.siens.com.br
>
> "Louie Miranda" <lmiranda <at> gmail.com> escreveu na mensagem
> news:5016fc50906300125s12389ae1v3323c63c30343fa1 <at> mail.gmail.com...
(Continue reading)

WenDong Zhang | 1 Jul 05:20 2009
Picon

Re: Cleaning up automatically when leaving a page

yes, the browser evoke unload event when leave the page (back, forward, or
close). you can send a message via ajax, but it may not been received by the
server successful, (when close the browser)

I think the best way is maintaining a timestamp as michael & paul say, and
clear the 'junk' timely.

there is another way if you need to get some INFO when user leaves this page
(such as leave time...):
 save the INFO into cache
 set time interval do the follow:
  1. load INFO from cache
  2. send the INFO via ajax and wait the server confirm it has received the
INFO
  3. if the server response is ture, delete the INFO or send the INFO again
a while later
by this way, even users closed their browser, but the next time they open
your web page, they will send the cached INFO too.

On Wed, Jul 1, 2009 at 10:59 AM, Paul M Foster <paulf <at> quillandmouse.com>wrote:

> On Tue, Jun 30, 2009 at 06:38:19PM -0700, Mary Anderson wrote:
>
> > Hi all,
> >
> >   I have a php application for which I have a page which creates
> > temporary junk and puts it into a persistent store  (in this case a
> > postgres database, but that is beside the point.)
> >
> >   I have a Save button which puts the stuff I really want into the
(Continue reading)


Gmane