Re: [PHP] While on the topic of PHP Web Site Stats - SharePoint...

2011-09-19 Thread Daniel Brown
On Mon, Sep 19, 2011 at 18:22, George Langley  wrote:
>        Hi all. Had a meeting today where I was rather condescendingly told 
> that most CMS web sites use SharePoint.

Well, you may reply, equally condescendingly, that you will need
that to have cited references, as it's simply incorrect.  According to
the latest survey conducted by w3techs.com[1], though SharePoint is
used on sites with some of the highest traffic on the Internet, its
saturation point is just 0.3%.

According to the survey, the five CMS platforms ahead of it in
popularity, in order, are (and quite expectedly): WordPress, Joomla!,
Drupal, vBulletin, and Blogger.  And of those five, one is a service
(blogger.com), and the rest are all open-source CMS systems ---
written in PHP.

-- 

Network Infrastructure Manager
http://www.php.net/

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



[PHP] While on the topic of PHP Web Site Stats - SharePoint...

2011-09-19 Thread George Langley
Hi all. Had a meeting today where I was rather condescendingly told 
that most CMS web sites use SharePoint. Last I checked:



Wordpress, Joomla! and Drupal (PHP, PHP and oh look, PHP) kind of had the CMS 
market wrapped up, with numerous other systems fighting for the remains. In 
fact, I don't see SharePoint even listed at the above link.

Any stats on (warning - buzzwords ahead) "External-facing" web sites 
using SharePoint?

At $$$ for the required server software, compared to <$ for just about 
anything PHP-based, can only imagine companies using SharePoint must have their 
IT department in charge of the web site. Am sure it's fine as an internal 
project management tool, but am very concerned when other developers tell me to 
run away from anyone who chooses to use SharePoint on anything public.
Thanks.


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



[PHP] Re: [Bulk] Re: [PHP] Re: [Bulk] Re: [PHP] Why [?php while (true) { sleep(5); } ?] dies on CLI?

2009-06-13 Thread Jean-Pierre Arneodo

Ashley Sheridan a écrit :

On Thu, 2009-06-11 at 20:52 +0200, Jean-Pierre Arneodo wrote:
  

Ashley Sheridan a écrit :


On Thu, 2009-06-11 at 10:47 +, Jean-Pierre Arneodo wrote:
  
  

Hi!
I'm stuck.
I don't understand why the php CLI dies after 3 hours in my script.
Any idea to solve?
Thanks


PHP 5.2.9-0.dotdeb.2 with Suhosin-Patch 0.9.7 (cli) (built: Apr  7 2009 
20:06:36)
Linux ubuntu  2.6.24-19-server #1 SMP Wed Jun 18 14:44:47 UTC 2008 x86_64 
GNU/Linux

Conf [php.ini]
max_execution_time=0




  



The while loop will continue executing until its condition is false. As
you've got a boolean true as the condition, it will never end.

Thanks
Ash
www.ashleysheridan.co.uk
  
  

I don't want to stop, but the process dies.

I've tried the same loop with bash interpretor.
Same result, it seems to be a ubuntu problem, not a php problem.

Thanks





Why do you want the process to continue indefinitely? Is it for a daemon
of some kind?

Thanks
Ash
www.ashleysheridan.co.uk

  
No, it isn't a daemon, but it does something and wait the end of 
processing by polling a daemon.


# ulimit -a
core file size  (blocks, -c) 0
data seg size   (kbytes, -d) unlimited
scheduling priority (-e) 0
file size   (blocks, -f) unlimited
pending signals (-i) 38912
max locked memory   (kbytes, -l) 32
max memory size (kbytes, -m) unlimited
open files  (-n) 1024
pipe size(512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
real-time priority  (-r) 0
stack size  (kbytes, -s) 8192
cpu time   (seconds, -t) unlimited
max user processes  (-u) 38912
virtual memory  (kbytes, -v) unlimited
file locks  (-x) unlimited




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



Re: [PHP] Re: [Bulk] Re: [PHP] Why [?php while (true) { sleep(5); } ?] dies on CLI?

2009-06-13 Thread Ashley Sheridan
On Thu, 2009-06-11 at 20:52 +0200, Jean-Pierre Arneodo wrote:
> Ashley Sheridan a écrit :
> > On Thu, 2009-06-11 at 10:47 +, Jean-Pierre Arneodo wrote:
> >   
> >> Hi!
> >> I'm stuck.
> >> I don't understand why the php CLI dies after 3 hours in my script.
> >> Any idea to solve?
> >> Thanks
> >>
> >>
> >> PHP 5.2.9-0.dotdeb.2 with Suhosin-Patch 0.9.7 (cli) (built: Apr  7 2009 
> >> 20:06:36)
> >> Linux ubuntu  2.6.24-19-server #1 SMP Wed Jun 18 14:44:47 UTC 2008 x86_64 
> >> GNU/Linux
> >>
> >> Conf [php.ini]
> >> max_execution_time=0
> >>
> >>  >> while (true) {
> >> sleep(5);
> >> }
> >> ?>
> >>
> >>
> >>   
> >> 
> > The while loop will continue executing until its condition is false. As
> > you've got a boolean true as the condition, it will never end.
> >
> > Thanks
> > Ash
> > www.ashleysheridan.co.uk
> >   
> I don't want to stop, but the process dies.
> 
> I've tried the same loop with bash interpretor.
> Same result, it seems to be a ubuntu problem, not a php problem.
> 
> Thanks
> 
> 
> 
Why do you want the process to continue indefinitely? Is it for a daemon
of some kind?

Thanks
Ash
www.ashleysheridan.co.uk


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



Re: [PHP] Re: [Bulk] Re: [PHP] Why [?php while (true) { sleep(5); } ?] dies on CLI?

2009-06-11 Thread Robert Cummings

Jean-Pierre Arneodo wrote:

Ashley Sheridan a écrit :

On Thu, 2009-06-11 at 10:47 +, Jean-Pierre Arneodo wrote:
 

Hi!
I'm stuck.
I don't understand why the php CLI dies after 3 hours in my script.
Any idea to solve?
Thanks


PHP 5.2.9-0.dotdeb.2 with Suhosin-Patch 0.9.7 (cli) (built: Apr  7 
2009 20:06:36)
Linux ubuntu  2.6.24-19-server #1 SMP Wed Jun 18 14:44:47 UTC 2008 
x86_64 GNU/Linux


Conf [php.ini]
max_execution_time=0




  

The while loop will continue executing until its condition is false. As
you've got a boolean true as the condition, it will never end.

Thanks
Ash
www.ashleysheridan.co.uk
  

I don't want to stop, but the process dies.

I've tried the same loop with bash interpretor.
Same result, it seems to be a ubuntu problem, not a php problem.


Open up a shell... type the following into it:

ulimit -a

What do you see?

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



[PHP] Re: [Bulk] Re: [PHP] Why [?php while (true) { sleep(5); } ?] dies on CLI?

2009-06-11 Thread Jean-Pierre Arneodo

Ashley Sheridan a écrit :

On Thu, 2009-06-11 at 10:47 +, Jean-Pierre Arneodo wrote:
  

Hi!
I'm stuck.
I don't understand why the php CLI dies after 3 hours in my script.
Any idea to solve?
Thanks


PHP 5.2.9-0.dotdeb.2 with Suhosin-Patch 0.9.7 (cli) (built: Apr  7 2009 
20:06:36)
Linux ubuntu  2.6.24-19-server #1 SMP Wed Jun 18 14:44:47 UTC 2008 x86_64 
GNU/Linux

Conf [php.ini]
max_execution_time=0




  


The while loop will continue executing until its condition is false. As
you've got a boolean true as the condition, it will never end.

Thanks
Ash
www.ashleysheridan.co.uk
  

I don't want to stop, but the process dies.

I've tried the same loop with bash interpretor.
Same result, it seems to be a ubuntu problem, not a php problem.

Thanks



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



RE: [PHP] Why [?php while (true) { sleep(5); } ?] dies on CLI?

2009-06-11 Thread kyle.smith
One of two things is happening:

- PHP is crashing, maybe a memory leak, etc.

Or

- That while(true) loop is exiting, and the script is completing.

Would be interesting to know which, try adding this after the loop:
$fp = fopen('/tmp/test','w');
fputs($fp, 'My script left the loop and exited cleanly.  True ==
false.');
fclose($fp);
 
Back on my first point, have you kept an eye on the memory usage over
the 3 hours?  If your version of PHP has a memory leak with while() or
sleep() (would be odd), a bazillion iterrations could break the PHP
defined memory limit (8M by default) and cause it to exit abruptly.

Are you capturing the output anywhere?  For example, in Linux is it
being run from cron or another script?  Try redirecting STDOUT and
STDERR somewhere useful, i.e.:

php my_php_script > /tmp/scriptoutput 2>&1

(2>&1 means "output stream 2 [stderr] to the same place as stream 1")

Hope any of these crazy ideas are helpful...
- Kyle

 
--
Kyle Smith
Unix Systems Administrator

-Original Message-
From: Robert Cummings [mailto:rob...@interjinn.com] 
Sent: Thursday, June 11, 2009 8:25 AM
To: Ford, Mike
Cc: php-general@lists.php.net
Subject: Re: [PHP] Why [?php while (true) { sleep(5); } ?] dies on CLI?

Ford, Mike wrote:
> On 11 June 2009 12:00, Ashley Sheridan advised:
> 
>> On Thu, 2009-06-11 at 10:47 +, Jean-Pierre Arneodo wrote:
>>> Hi!
>>> I'm stuck.
>>> I don't understand why the php CLI dies after 3 hours in my script.
> Any
>>> idea to solve? Thanks
>>>
>>>
>>> PHP 5.2.9-0.dotdeb.2 with Suhosin-Patch 0.9.7 (cli) (built: Apr  7
> 2009
>>> 20:06:36) Linux ubuntu  2.6.24-19-server #1 SMP Wed Jun 18 14:44:47
> UTC
>>> 2008 x86_64 GNU/Linux
>>>
>>> Conf [php.ini]
>>> max_execution_time=0
>>>
>>> >> while (true) {
>>> sleep(5);
>>> }
>>>
>>>
>> The while loop will continue executing until its condition is false.
> As
>> you've got a boolean true as the condition, it will never end.
> 
> I think he realises that. His question is why "never" equates to 3 
> hours in his environment.

Shouldn't be max execution time issue if he's running the CLI. Maybe
account limits? Maybe the above snippet isn't what's really happening...

I mean what purpose would the above script serve for 3 hours? Looks like
it's been dumbed down for us dummies on the list.

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


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



Re: [PHP] Why [?php while (true) { sleep(5); } ?] dies on CLI?

2009-06-11 Thread Robert Cummings

Ford, Mike wrote:

On 11 June 2009 12:00, Ashley Sheridan advised:


On Thu, 2009-06-11 at 10:47 +, Jean-Pierre Arneodo wrote:

Hi!
I'm stuck.
I don't understand why the php CLI dies after 3 hours in my script.

Any

idea to solve? Thanks


PHP 5.2.9-0.dotdeb.2 with Suhosin-Patch 0.9.7 (cli) (built: Apr  7

2009

20:06:36) Linux ubuntu  2.6.24-19-server #1 SMP Wed Jun 18 14:44:47

UTC
2008 x86_64 GNU/Linux 


Conf [php.ini]
max_execution_time=0


The while loop will continue executing until its condition is false.

As

you've got a boolean true as the condition, it will never end.


I think he realises that. His question is why "never" equates to 3 hours
in his environment.


Shouldn't be max execution time issue if he's running the CLI. Maybe 
account limits? Maybe the above snippet isn't what's really happening... 
I mean what purpose would the above script serve for 3 hours? Looks like 
it's been dumbed down for us dummies on the list.


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] Why [?php while (true) { sleep(5); } ?] dies on CLI?

2009-06-11 Thread Eddie Drapkin
try set_time_limit(0) ?

On Thu, Jun 11, 2009 at 8:05 AM, Ford, Mike  wrote:

> On 11 June 2009 12:00, Ashley Sheridan advised:
>
> > On Thu, 2009-06-11 at 10:47 +, Jean-Pierre Arneodo wrote:
> >> Hi!
> >> I'm stuck.
> >> I don't understand why the php CLI dies after 3 hours in my script.
> Any
> >> idea to solve? Thanks
> >>
> >>
> >> PHP 5.2.9-0.dotdeb.2 with Suhosin-Patch 0.9.7 (cli) (built: Apr  7
> 2009
> >> 20:06:36) Linux ubuntu  2.6.24-19-server #1 SMP Wed Jun 18 14:44:47
> UTC
> >> 2008 x86_64 GNU/Linux
> >>
> >> Conf [php.ini]
> >> max_execution_time=0
> >>
> >>  >> while (true) {
> >> sleep(5);
> >> }
> >>>
> >>
> >>
> >>
> > The while loop will continue executing until its condition is false.
> As
> > you've got a boolean true as the condition, it will never end.
>
> I think he realises that. His question is why "never" equates to 3 hours
> in his environment.
>
> Cheers!
>
> Mike
>
>  --
> Mike Ford,  Electronic Information Developer,
> C507, Leeds Metropolitan University, Civic Quarter Campus,
> Woodhouse Lane, LEEDS,  LS1 3HE,  United Kingdom
> Email: m.f...@leedsmet.ac.uk
> Tel: +44 113 812 4730
>
>
> 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] Why [?php while (true) { sleep(5); } ?] dies on CLI?

2009-06-11 Thread Ford, Mike
On 11 June 2009 12:00, Ashley Sheridan advised:

> On Thu, 2009-06-11 at 10:47 +, Jean-Pierre Arneodo wrote:
>> Hi!
>> I'm stuck.
>> I don't understand why the php CLI dies after 3 hours in my script.
Any
>> idea to solve? Thanks
>> 
>> 
>> PHP 5.2.9-0.dotdeb.2 with Suhosin-Patch 0.9.7 (cli) (built: Apr  7
2009
>> 20:06:36) Linux ubuntu  2.6.24-19-server #1 SMP Wed Jun 18 14:44:47
UTC
>> 2008 x86_64 GNU/Linux 
>> 
>> Conf [php.ini]
>> max_execution_time=0
>> 
>> > while (true) {
>> sleep(5);
>> }
>>> 
>> 
>> 
>> 
> The while loop will continue executing until its condition is false.
As
> you've got a boolean true as the condition, it will never end.

I think he realises that. His question is why "never" equates to 3 hours
in his environment.

Cheers!

Mike

 --
Mike Ford,  Electronic Information Developer,
C507, Leeds Metropolitan University, Civic Quarter Campus, 
Woodhouse Lane, LEEDS,  LS1 3HE,  United Kingdom
Email: m.f...@leedsmet.ac.uk
Tel: +44 113 812 4730


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] Why [?php while (true) { sleep(5); } ?] dies on CLI?

2009-06-11 Thread Ashley Sheridan
On Thu, 2009-06-11 at 10:47 +, Jean-Pierre Arneodo wrote:
> Hi!
> I'm stuck.
> I don't understand why the php CLI dies after 3 hours in my script.
> Any idea to solve?
> Thanks
> 
> 
> PHP 5.2.9-0.dotdeb.2 with Suhosin-Patch 0.9.7 (cli) (built: Apr  7 2009 
> 20:06:36)
> Linux ubuntu  2.6.24-19-server #1 SMP Wed Jun 18 14:44:47 UTC 2008 x86_64 
> GNU/Linux
> 
> Conf [php.ini]
> max_execution_time=0
> 
>  while (true) {
> sleep(5);
> }
> ?>
> 
> 
>   
The while loop will continue executing until its condition is false. As
you've got a boolean true as the condition, it will never end.

Thanks
Ash
www.ashleysheridan.co.uk


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



[PHP] Why [?php while (true) { sleep(5); } ?] dies on CLI?

2009-06-11 Thread Jean-Pierre Arneodo
Hi!
I'm stuck.
I don't understand why the php CLI dies after 3 hours in my script.
Any idea to solve?
Thanks


PHP 5.2.9-0.dotdeb.2 with Suhosin-Patch 0.9.7 (cli) (built: Apr  7 2009 
20:06:36)
Linux ubuntu  2.6.24-19-server #1 SMP Wed Jun 18 14:44:47 UTC 2008 x86_64 
GNU/Linux

Conf [php.ini]
max_execution_time=0




  

Re: [PHP] [php] while loop failure

2009-04-06 Thread Virgilio Quilario
> setting:
>
> max_execution_time = -1     ; Maximum execution time of each script, in
> seconds
> max_input_time = -1    ; Maximum amount of time each script may spend
> parsing request data
> ;max_input_nesting_level = 64 ; Maximum input variable nesting level
> memory_limit = 2036M      ; Maximum amount of memory a script may consume
> (128MB)
>
> the above setting should allowed script to execute indefinitely. is't it?
>

hi,

should it be this setting that allows the script to run forever?
max_execution_time = 0;

also when script runs from command line, max_execution_time defaults to zero.

cheers,
virgil
http://www.jampmark.com

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



Re: [PHP] [php] while loop failure

2009-04-06 Thread Virgilio Quilario
> Does any one knows why while loop below ends after few loops when it meant
> to keep in loop?
>
> File name: while_loop_script.php
>
> define('run', 0);
> define('START', 10);
>
> while(START >run){
>
> $ch = curl_init("mydomain/update_script.php?action=run");
> curl_exec($ch);
> curl_close($ch);
>
> }
>
> using php.exe to scheldule task it every 5 minutes:
>
> C:\php.exe D:\update\while_loop_script.php
>
> --
> www.willandy.co.uk
>

hi,

maybe you should put
error_reporting(E_ALL);
ini_set('display_errors', true);

with the setting above, run the script
C:\php.exe D:\update\while_loop_script.php

you should see errors when script ends.

virgil
http://www.jampmark.com

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



Re: [PHP] [php] while loop failure

2009-04-06 Thread Andrew Williams
setting:

max_execution_time = -1 ; Maximum execution time of each script, in
seconds
max_input_time = -1; Maximum amount of time each script may spend
parsing request data
;max_input_nesting_level = 64 ; Maximum input variable nesting level
memory_limit = 2036M  ; Maximum amount of memory a script may consume
(128MB)

the above setting should allowed script to execute indefinitely. is't it?

On Mon, Apr 6, 2009 at 11:29 AM, Andrew Williams
wrote:

> The php.ini maximum time is set to -1 which is infinity
>
>
> On Mon, Apr 6, 2009 at 11:27 AM, Chetan Rane  > wrote:
>
>> I think its exceeding the max execution time set in PHP.ini
>> Either set yoru cron to run after every 60 seconds, or change the setting
>> in PHP.ini
>>
>> Chetan Dattaram Rane | Software Engineer | Persistent Systems
>> chetan_r...@persistent.co.in  | Cell: +91 94033 66714 | Tel: +91 (0832)
>> 30 79014
>> Innovation in software product design, development and delivery-
>> www.persistentsys.com
>>
>>
>>
>>
>> -Original Message-
>> From: Andrew Williams [mailto:andrew4willi...@gmail.com]
>> Sent: Monday, April 06, 2009 3:51 PM
>> To: php-general@lists.php.net
>> Subject: [PHP] [php] while loop failure
>>
>> Does any one knows why while loop below ends after few loops when it meant
>> to keep in loop?
>>
>> File name: while_loop_script.php
>>
>> define('run', 0);
>> define('START', 10);
>>
>> while(START >run){
>>
>> $ch = curl_init("mydomain/update_script.php?action=run");
>> curl_exec($ch);
>> curl_close($ch);
>>
>> }
>>
>> using php.exe to scheldule task it every 5 minutes:
>>
>> C:\php.exe D:\update\while_loop_script.php
>>
>> --
>> www.willandy.co.uk
>>
>> DISCLAIMER
>> ==
>> This e-mail may contain privileged and confidential information which is
>> the property of Persistent Systems Ltd. It is intended only for the use of
>> the individual or entity to which it is addressed. If you are not the
>> intended recipient, you are not authorized to read, retain, copy, print,
>> distribute or use this message. If you have received this communication in
>> error, please notify the sender and delete all copies of this message.
>> Persistent Systems Ltd. does not accept any liability for virus infected
>> mails.
>>
>
>
>
> --
> Best Wishes
> Andrew Williams
>
>
>


-- 
Best Wishes
Andrew Williams


Re: [PHP] [php] while loop failure

2009-04-06 Thread Andrew Williams
The php.ini maximum time is set to -1 which is infinity

On Mon, Apr 6, 2009 at 11:27 AM, Chetan Rane
wrote:

> I think its exceeding the max execution time set in PHP.ini
> Either set yoru cron to run after every 60 seconds, or change the setting
> in PHP.ini
>
> Chetan Dattaram Rane | Software Engineer | Persistent Systems
> chetan_r...@persistent.co.in  | Cell: +91 94033 66714 | Tel: +91 (0832) 30
> 79014
> Innovation in software product design, development and delivery-
> www.persistentsys.com
>
>
>
>
> -Original Message-
> From: Andrew Williams [mailto:andrew4willi...@gmail.com]
> Sent: Monday, April 06, 2009 3:51 PM
> To: php-general@lists.php.net
> Subject: [PHP] [php] while loop failure
>
> Does any one knows why while loop below ends after few loops when it meant
> to keep in loop?
>
> File name: while_loop_script.php
>
> define('run', 0);
> define('START', 10);
>
> while(START >run){
>
> $ch = curl_init("mydomain/update_script.php?action=run");
> curl_exec($ch);
> curl_close($ch);
>
> }
>
> using php.exe to scheldule task it every 5 minutes:
>
> C:\php.exe D:\update\while_loop_script.php
>
> --
> www.willandy.co.uk
>
> DISCLAIMER
> ==
> This e-mail may contain privileged and confidential information which is
> the property of Persistent Systems Ltd. It is intended only for the use of
> the individual or entity to which it is addressed. If you are not the
> intended recipient, you are not authorized to read, retain, copy, print,
> distribute or use this message. If you have received this communication in
> error, please notify the sender and delete all copies of this message.
> Persistent Systems Ltd. does not accept any liability for virus infected
> mails.
>



-- 
Best Wishes
Andrew Williams


RE: [PHP] [php] while loop failure

2009-04-06 Thread Chetan Rane
I think its exceeding the max execution time set in PHP.ini
Either set yoru cron to run after every 60 seconds, or change the setting in 
PHP.ini

Chetan Dattaram Rane | Software Engineer | Persistent Systems
chetan_r...@persistent.co.in  | Cell: +91 94033 66714 | Tel: +91 (0832) 30 79014
Innovation in software product design, development and delivery- 
www.persistentsys.com




-Original Message-
From: Andrew Williams [mailto:andrew4willi...@gmail.com]
Sent: Monday, April 06, 2009 3:51 PM
To: php-general@lists.php.net
Subject: [PHP] [php] while loop failure

Does any one knows why while loop below ends after few loops when it meant
to keep in loop?

File name: while_loop_script.php

define('run', 0);
define('START', 10);

while(START >run){

$ch = curl_init("mydomain/update_script.php?action=run");
curl_exec($ch);
curl_close($ch);

}

using php.exe to scheldule task it every 5 minutes:

C:\php.exe D:\update\while_loop_script.php

--
www.willandy.co.uk

DISCLAIMER
==
This e-mail may contain privileged and confidential information which is the 
property of Persistent Systems Ltd. It is intended only for the use of the 
individual or entity to which it is addressed. If you are not the intended 
recipient, you are not authorized to read, retain, copy, print, distribute or 
use this message. If you have received this communication in error, please 
notify the sender and delete all copies of this message. Persistent Systems 
Ltd. does not accept any liability for virus infected mails.

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



[PHP] [php] while loop failure

2009-04-06 Thread Andrew Williams
Does any one knows why while loop below ends after few loops when it meant
to keep in loop?

File name: while_loop_script.php

define('run', 0);
define('START', 10);

while(START >run){

$ch = curl_init("mydomain/update_script.php?action=run");
curl_exec($ch);
curl_close($ch);

}

using php.exe to scheldule task it every 5 minutes:

C:\php.exe D:\update\while_loop_script.php

-- 
www.willandy.co.uk


RE: [PHP] WHILE LOOP PROBLEM

2009-03-27 Thread Arno Kuhl
-Original Message-
From: Andrew Williams [mailto:andrew4willi...@gmail.com] 
Sent: 27 March 2009 10:12 AM
To: PHP LIST
Subject: [PHP] WHILE LOOP PROBLEM

can some tell why the below loop stop running after some time.

$start=10;
const run=0;
while($start >run){

//do somthing

}

--

The webserver or php environment is probably terminating the script. It will
only run for the max number of seconds set in your php.ini file.

Arno


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



Re: [PHP] WHILE LOOP PROBLEM

2009-03-27 Thread Craig Whitmore
On Fri, 2009-03-27 at 08:11 +, Andrew Williams wrote:
> can some tell why the below loop stop running after some time.
> 
> $start=10;
> const run=0;
> while($start >run){
> 
> //do somthing
> 
> }
> 
max_execution_time


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



[PHP] WHILE LOOP PROBLEM

2009-03-27 Thread Andrew Williams
can some tell why the below loop stop running after some time.

$start=10;
const run=0;
while($start >run){

//do somthing

}

-- 
Best Wishes
Andrew Williams


Re: [PHP] while-question

2008-11-19 Thread Shawn McKenzie
bruce wrote:
> interesting points regarding college and programming..
> 
> my degrees bsee/msee covered alot more than pure programing.. as a double 
> ee/cs, the ability to articulate an issue/problem, and bring to mind a cogent 
> thought process was valuable. the ability to understand how different 
> algorithms worked, and how code actually played with the lower intracacies of 
> the processor where quite valuable. 
> 
> and no.. i'm no longer the engineer i was a time ago..
> 
> so.. interesting...
> 

They must have been case-insensitive languages, unlike English.  :-)

-Shawn

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



RE: [PHP] while-question

2008-11-19 Thread bruce
interesting points regarding college and programming..

my degrees bsee/msee covered alot more than pure programing.. as a double 
ee/cs, the ability to articulate an issue/problem, and bring to mind a cogent 
thought process was valuable. the ability to understand how different 
algorithms worked, and how code actually played with the lower intracacies of 
the processor where quite valuable. 

and no.. i'm no longer the engineer i was a time ago..

so.. interesting...


-Original Message-
From: Wolf [mailto:[EMAIL PROTECTED]
Sent: Monday, November 17, 2008 11:55 AM
To: tedd
Cc: php-general@lists.php.net
Subject: RE: [PHP] while-question


> Dabbling?
> 
> I think that making a living from it isn't dabbling, so I may not be 
> qualified to speak for the dabblers.
> 
> But for me, I was writing code before there were such courses. Later, 
> when I went to college I was taught adventures in keypunching and 
> received several "next to worthless" degrees.
> 
> I say "next to worthless" only because what they taught really wasn't 
> applicable to real world programming. As for management, clients, and 
> hr types, the degrees mattered, but not for much more than that.
> 
> In any event, I doubt if any college courses are keeping up with 
> current web technology -- there has always been a lag between what's 
> practiced and what's taught. What I've seen of college web sites, 
> seems to support that claim.
> 
> If I was taught in college all I needed to know, then what am I doing 
> with these dozens of web books scattered about my office? I probably 
> read a new book every other week.

I don't "dabble" in it either, unless you consider making my living from being 
a dabbler, in which case I'll continue to dabble and see the pay for it.  My 
alma-mater tried to stay current to some degree, but when they let someone who 
wrote the C++ book try to teach it, well they gave that person more rope then 
they needed.

Tedd, glad you got hooked on Phonics.  One of these days I hope from graduating 
from just looking at the pictures, but right now the pictures are oh so 
enticing!. ;)  

Wolf

-- 
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] while question

2008-11-18 Thread Ashley Sheridan
On Tue, 2008-11-18 at 10:52 +, Nathan Rixham wrote:
> Ashley Sheridan wrote:
> > On Mon, 2008-11-17 at 18:01 -0500, Craige Leeder wrote:
> >> Ashley Sheridan wrote:
> >>> On Mon, 2008-11-17 at 17:47 -0500, Craige Leeder wrote:
> >>>   
>  Only thing to note with the foreach is that you are actually working on 
>  a copy of the array, so if you intend to modify it, pass it by reference.
> 
>  - Craige
>  
> >>> Can you do that? I assume it would look like this:
> >>>
> >>> foreach(&$array as $a) {}
> >>>   
> >> Close. It actually looks like this:
> >>
> >> foreach ($array as $key => &$value)  {}
> >>
> >> This makes sense because for each  iteration of the loop, PHP places a 
> >> copy of the key in $key, and a copy of the value in $value. Therefor, 
> >> you are specifying with this code that you want it to place a reference 
> >> of the value into $value.
> >>
> >> - Craige
> >>
> >>
> >>
> > Ah, that could be very useful to know, thanks!
> > 
> > 
> > Ash
> > www.ashleysheridan.co.uk
> > 
> 
> foreach ($array as $key => $value)
> 
> $value = a copy so won't change the original array
> $array[$key] = the original
> 
> thus:
> 
> foreach ($array as $key => $value) {
>   $array[$key] = do_something_with($value);
> }
> 
This is how I've always done it 'til now, but I think passing by
reference is a bit neater in its approach, and can be easier to read
when $value is itself an array or complex object.


Ash
www.ashleysheridan.co.uk


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



Re: [PHP] while-question

2008-11-18 Thread Robert Cummings
On Tue, 2008-11-18 at 14:33 +, Nathan Rixham wrote:
> Craige Leeder wrote:
> > Jochem Maas wrote:
> >> klieder ... kliederen
> >>
> >> the E sound is short.
> >>
> >>   
> > Interesting to know. Thanks :D
> > 
> > - Craige
> 
> don't believe him, "jochem" is really called Bob Davis, a slightly 
> balding middle aged ASP developer from hull

Ahhh... Hull... I have memories of thee. 15 years ago between 1am and
3am that was the place to head after the Ottawa bars closed and you
wanted to squeeze in another 2 hours of binging.

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] while-question

2008-11-18 Thread Bastien Koert
On Tue, Nov 18, 2008 at 9:33 AM, Nathan Rixham <[EMAIL PROTECTED]> wrote:

> Craige Leeder wrote:
>
>> Jochem Maas wrote:
>>
>>> klieder ... kliederen
>>>
>>> the E sound is short.
>>>
>>>
>>>
>> Interesting to know. Thanks :D
>>
>> - Craige
>>
>
> don't believe him, "jochem" is really called Bob Davis, a slightly balding
> middle aged ASP developer from hull sent to infiltrate the PHP community and
> misguide the weak with tales of short sounding letters.
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
Is this where we starting singing

'Pass the dutchie on the left hand side'?



-- 

Bastien

Cat, the other other white meat


Re: [PHP] while-question

2008-11-18 Thread Nathan Rixham

Craige Leeder wrote:

Jochem Maas wrote:

klieder ... kliederen

the E sound is short.

  

Interesting to know. Thanks :D

- Craige


don't believe him, "jochem" is really called Bob Davis, a slightly 
balding middle aged ASP developer from hull sent to infiltrate the PHP 
community and misguide the weak with tales of short sounding letters.


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



Re: [PHP] while-question

2008-11-18 Thread Craige Leeder

Jochem Maas wrote:

klieder ... kliederen

the E sound is short.

  

Interesting to know. Thanks :D

- Craige

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



Re: [PHP] while-question

2008-11-18 Thread Jochem Maas
Craige Leeder schreef:
> Jochem Maas wrote:
>> just for laughs .. given the 'dabble' thread "Cleeder" is phonetically
>> very very close to a dutch word meaning 'messing around' .. rather in
>> the way
>> a 2yo might mess around with a bowl of yogurt.
>>   
> Haha, now that does make me laugh. Out of curiosity, what is the actual
> word for it?  

klieder ... kliederen

the E sound is short.

> 


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



Re: [PHP] while-question

2008-11-18 Thread Craige Leeder

Jochem Maas wrote:

just for laughs .. given the 'dabble' thread "Cleeder" is phonetically
very very close to a dutch word meaning 'messing around' .. rather in the way
a 2yo might mess around with a bowl of yogurt.
  
Haha, now that does make me laugh. Out of curiosity, what is the actual 
word for it?


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



Re: [PHP] while-question

2008-11-18 Thread Nathan Rixham

tedd wrote:

At 7:02 PM -0500 11/17/08, Craige Leeder wrote:

I'm not illiterate; promise :p

- Craige



Yeah, his parents were married before he was born.

Cheers,

tedd



omg tedd, I was just reading this thread over, thought exactly that 
witty response, clicked you're reply and there it is; masterful!


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



Re: [PHP] while question

2008-11-18 Thread Nathan Rixham

Ashley Sheridan wrote:

On Mon, 2008-11-17 at 18:01 -0500, Craige Leeder wrote:

Ashley Sheridan wrote:

On Mon, 2008-11-17 at 17:47 -0500, Craige Leeder wrote:
  
Only thing to note with the foreach is that you are actually working on 
a copy of the array, so if you intend to modify it, pass it by reference.


- Craige


Can you do that? I assume it would look like this:

foreach(&$array as $a) {}
  

Close. It actually looks like this:

foreach ($array as $key => &$value)  {}

This makes sense because for each  iteration of the loop, PHP places a 
copy of the key in $key, and a copy of the value in $value. Therefor, 
you are specifying with this code that you want it to place a reference 
of the value into $value.


- Craige




Ah, that could be very useful to know, thanks!


Ash
www.ashleysheridan.co.uk



foreach ($array as $key => $value)

$value = a copy so won't change the original array
$array[$key] = the original

thus:

foreach ($array as $key => $value) {
 $array[$key] = do_something_with($value);
}

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



Re: [PHP] while-question

2008-11-17 Thread Jochem Maas
Craige Leeder schreef:
> Jochem Maas wrote:
>> must  . resist 
>>
>> "I take you didn't score to hig on the spelling test? and collage,
>> is that the the cut-n-paste school of IT?"
>>
>>  dang it, failed. ;-)
>>   
> 
> 
> Haha! 'high' was just my 'h' key not pressing, and college is just one
> of those words I have trouble with.

I demand credit for the utter brilliance of the cut-n-paste crack ;-)

> 
> I'm not illiterate; promise :p

:-)

> 
> - Craige

just for laughs .. given the 'dabble' thread "Cleeder" is phonetically
very very close to a dutch word meaning 'messing around' .. rather in the way
a 2yo might mess around with a bowl of yogurt.

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



Re: [PHP] while-question

2008-11-17 Thread Jochem Maas
tedd schreef:
> At 12:52 AM +0100 11/18/08, Jochem Maas wrote:
>> Craige Leeder schreef:
>>  > I'm 100% self taught for now. I'm just out of higschool, and hopefully
>>>  going off to collage next year.
>>
>> must  . resist 
>>
>> "I take you didn't score to hig on the spelling test? and collage,
>> is that the the cut-n-paste school of IT?"
>>
>>  dang it, failed. ;-)
> 
> Hang in there Jochem -- he's probably smarter than we were when we were
> his age.

pity the poor soul ;-) being clever only gets you deeper into 'dabble'. :-P

> Cheers,
> 
> tedd


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



Re: [PHP] while question

2008-11-17 Thread Micah Gersten
Jay Blanchard wrote:
> [snip]
> ...foreach...
> [/snip]
>
> You could also use a for loop if you wanted to count;
>
> for($i = 0; $i < count($array); $i++){
>echo $i . "\n";
> }
>
>
>   

This is not good because you are calling count every loop iteration.

Thank you,
Micah Gersten
onShore Networks
Internal Developer
http://www.onshore.com




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



Re: [PHP] while-question

2008-11-17 Thread tedd

At 7:02 PM -0500 11/17/08, Craige Leeder wrote:

I'm not illiterate; promise :p

- Craige



Yeah, his parents were married before he was born.

Cheers,

tedd



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

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



Re: [PHP] while-question

2008-11-17 Thread tedd

At 12:52 AM +0100 11/18/08, Jochem Maas wrote:

Craige Leeder schreef:
 > I'm 100% self taught for now. I'm just out of higschool, and hopefully

 going off to collage next year.


must  . resist 

"I take you didn't score to hig on the spelling test? and collage,
is that the the cut-n-paste school of IT?"

 dang it, failed. ;-)


Hang in there Jochem -- he's probably smarter than we were when we 
were his age.


Cheers,

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

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



Re: [PHP] while question

2008-11-17 Thread Jochem Maas
Craige Leeder schreef:
> Ashley Sheridan wrote:
>> On Mon, 2008-11-17 at 17:47 -0500, Craige Leeder wrote:
>>  
>>> Only thing to note with the foreach is that you are actually working
>>> on a copy of the array, so if you intend to modify it, pass it by
>>> reference.
>>>
>>> - Craige
>>> 
>> Can you do that? I assume it would look like this:
>>
>> foreach(&$array as $a) {}
>>   
> 
> Close. It actually looks like this:
> 
> foreach ($array as $key => &$value)  {}
> 
> This makes sense because for each  iteration of the loop, PHP places a
> copy of the key in $key, and a copy of the value in $value. Therefor,
> you are specifying with this code that you want it to place a reference
> of the value into $value.

indeed but beware, using a variable named $value after such a foreach loop
in the same scope will lead to all sorts of things you don't expect.

> 
> - Craige
> 
> 
> 


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



Re: [PHP] while-question

2008-11-17 Thread Craige Leeder

Jochem Maas wrote:

must  . resist 

"I take you didn't score to hig on the spelling test? and collage,
is that the the cut-n-paste school of IT?"

 dang it, failed. ;-)
  



Haha! 'high' was just my 'h' key not pressing, and college is just one 
of those words I have trouble with.



I'm not illiterate; promise :p

- Craige

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



Re: [PHP] while-question

2008-11-17 Thread Jochem Maas
tedd schreef:
> At 10:00 AM -0800 11/17/08, bruce wrote:
>> curious qiestion
>>
>> to all on here who dabble in php... how many of you have actully gone to
>> college, taken algorithm courses, microprocessor courses,
>> design/architecture courses, etc..
>>
>> or is the majority of the work here from people who've grabbed the
>> tools and
>> started programming... ?
> 
> 
> Dabbling?

Im neck deep in dabble every other week .. obviously it's always
someone else dabble ;-)


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



Re: [PHP] while-question

2008-11-17 Thread Jochem Maas
Craige Leeder schreef:
> bruce wrote:
>> curious qiestion
>>
>> to all on here who dabble in php... how many of you have actully gone to
>> college, taken algorithm courses, microprocessor courses,
>> design/architecture courses, etc..
>>
>> or is the majority of the work here from people who've grabbed the
>> tools and
>> started programming... ?
>>   
> 
> I'm 100% self taught for now. I'm just out of higschool, and hopefully
> going off to collage next year.

must  . resist 

"I take you didn't score to hig on the spelling test? and collage,
is that the the cut-n-paste school of IT?"

 dang it, failed. ;-)


> Everything I've learned at this stage is from books, tutorials, and
> experience.
> 
> - Craige
> 


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



Re: [PHP] while-question

2008-11-17 Thread Craige Leeder

bruce wrote:

curious qiestion

to all on here who dabble in php... how many of you have actully gone to
college, taken algorithm courses, microprocessor courses,
design/architecture courses, etc..

or is the majority of the work here from people who've grabbed the tools and
started programming... ?
  


I'm 100% self taught for now. I'm just out of higschool, and hopefully 
going off to collage next year.


Everything I've learned at this stage is from books, tutorials, and 
experience.


- Craige

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



Re: [PHP] while question

2008-11-17 Thread Ashley Sheridan
On Mon, 2008-11-17 at 18:01 -0500, Craige Leeder wrote:
> Ashley Sheridan wrote:
> > On Mon, 2008-11-17 at 17:47 -0500, Craige Leeder wrote:
> >   
> >> Only thing to note with the foreach is that you are actually working on 
> >> a copy of the array, so if you intend to modify it, pass it by reference.
> >>
> >> - Craige
> >> 
> > Can you do that? I assume it would look like this:
> >
> > foreach(&$array as $a) {}
> >   
> 
> Close. It actually looks like this:
> 
> foreach ($array as $key => &$value)  {}
> 
> This makes sense because for each  iteration of the loop, PHP places a 
> copy of the key in $key, and a copy of the value in $value. Therefor, 
> you are specifying with this code that you want it to place a reference 
> of the value into $value.
> 
> - Craige
> 
> 
> 
Ah, that could be very useful to know, thanks!


Ash
www.ashleysheridan.co.uk


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



Re: [PHP] while question

2008-11-17 Thread Craige Leeder

Ashley Sheridan wrote:

On Mon, 2008-11-17 at 17:47 -0500, Craige Leeder wrote:
  
Only thing to note with the foreach is that you are actually working on 
a copy of the array, so if you intend to modify it, pass it by reference.


- Craige


Can you do that? I assume it would look like this:

foreach(&$array as $a) {}
  


Close. It actually looks like this:

foreach ($array as $key => &$value)  {}

This makes sense because for each  iteration of the loop, PHP places a 
copy of the key in $key, and a copy of the value in $value. Therefor, 
you are specifying with this code that you want it to place a reference 
of the value into $value.


- Craige



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



Re: [PHP] while question

2008-11-17 Thread Ashley Sheridan
On Mon, 2008-11-17 at 17:47 -0500, Craige Leeder wrote:
> Alain Roger wrote:
> > Hi,
> >
> > i'm on PHP training and our lector is telling us that to avoid counting an
> > array item amout thanks count($my_array), he tells we can do:
> > while($my_array)
> > {
> >  ... do something
> > }
> > but from experience this is an infinity loop...
> >
> > it should be always something like
> > $count = count($my_array);
> > while($i <= $count)
> > {
> > ...
> > do something
> > ...
> > $i++;
> > }
> >
> > has someone already use such syntax ? i mean as the first one.
> > thx.
> >   
> While you teacher technically is wrong, you probably could implement 
> something using the next() and current() array functions, though you're 
> best to just use a foreach loop. foreach was designed specifically as an 
> array looping construct, so it's optimized pretty well.
> 
> Only thing to note with the foreach is that you are actually working on 
> a copy of the array, so if you intend to modify it, pass it by reference.
> 
> - Craige
> 
> 
> 
Can you do that? I assume it would look like this:

foreach(&$array as $a) {}


Ash
www.ashleysheridan.co.uk


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



Re: [PHP] while question

2008-11-17 Thread Craige Leeder

Alain Roger wrote:

Hi,

i'm on PHP training and our lector is telling us that to avoid counting an
array item amout thanks count($my_array), he tells we can do:
while($my_array)
{
 ... do something
}
but from experience this is an infinity loop...

it should be always something like
$count = count($my_array);
while($i <= $count)
{
...
do something
...
$i++;
}

has someone already use such syntax ? i mean as the first one.
thx.
  
While you teacher technically is wrong, you probably could implement 
something using the next() and current() array functions, though you're 
best to just use a foreach loop. foreach was designed specifically as an 
array looping construct, so it's optimized pretty well.


Only thing to note with the foreach is that you are actually working on 
a copy of the array, so if you intend to modify it, pass it by reference.


- Craige



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



RE: [PHP] while-question

2008-11-17 Thread tedd

At 2:55 PM -0500 11/17/08, Wolf wrote:
Tedd, glad you got hooked on Phonics.  One of these days I hope from 
graduating from just looking at the pictures, but right now the 
pictures are oh so enticing!. ;) 


Wolf


Wolf:

Lot's of exciting things -- hard to keep up on bots, automated 
buying, data mining, and other such things that make my head hurt.


Cheers,

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

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



RE: [PHP] while-question

2008-11-17 Thread Wolf
> Dabbling?
> 
> I think that making a living from it isn't dabbling, so I may not be 
> qualified to speak for the dabblers.
> 
> But for me, I was writing code before there were such courses. Later, 
> when I went to college I was taught adventures in keypunching and 
> received several "next to worthless" degrees.
> 
> I say "next to worthless" only because what they taught really wasn't 
> applicable to real world programming. As for management, clients, and 
> hr types, the degrees mattered, but not for much more than that.
> 
> In any event, I doubt if any college courses are keeping up with 
> current web technology -- there has always been a lag between what's 
> practiced and what's taught. What I've seen of college web sites, 
> seems to support that claim.
> 
> If I was taught in college all I needed to know, then what am I doing 
> with these dozens of web books scattered about my office? I probably 
> read a new book every other week.

I don't "dabble" in it either, unless you consider making my living from being 
a dabbler, in which case I'll continue to dabble and see the pay for it.  My 
alma-mater tried to stay current to some degree, but when they let someone who 
wrote the C++ book try to teach it, well they gave that person more rope then 
they needed.

Tedd, glad you got hooked on Phonics.  One of these days I hope from graduating 
from just looking at the pictures, but right now the pictures are oh so 
enticing!. ;)  

Wolf

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



RE: [PHP] while-question

2008-11-17 Thread tedd

At 10:00 AM -0800 11/17/08, bruce wrote:

curious qiestion

to all on here who dabble in php... how many of you have actully gone to
college, taken algorithm courses, microprocessor courses,
design/architecture courses, etc..

or is the majority of the work here from people who've grabbed the tools and
started programming... ?



Dabbling?

I think that making a living from it isn't dabbling, so I may not be 
qualified to speak for the dabblers.


But for me, I was writing code before there were such courses. Later, 
when I went to college I was taught adventures in keypunching and 
received several "next to worthless" degrees.


I say "next to worthless" only because what they taught really wasn't 
applicable to real world programming. As for management, clients, and 
hr types, the degrees mattered, but not for much more than that.


In any event, I doubt if any college courses are keeping up with 
current web technology -- there has always been a lag between what's 
practiced and what's taught. What I've seen of college web sites, 
seems to support that claim.


If I was taught in college all I needed to know, then what am I doing 
with these dozens of web books scattered about my office? I probably 
read a new book every other week.


Cheers,

tedd

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

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



Re: [PHP] while-question

2008-11-17 Thread Nathan Rixham

bruce wrote:

curious qiestion

to all on here who dabble in php... how many of you have actully gone to
college, taken algorithm courses, microprocessor courses,
design/architecture courses, etc..

or is the majority of the work here from people who've grabbed the tools and
started programming... ?



the bulk of it self taught and via vast amounts of reading and many 
years of on the job experience (needs must), some formal education in 
the form of a year wasted getting a diploma whenst I was young (mainly 
as the topics covered where out of date and unused in general business).


HOWEVER, (a big one) I've recently converted, never really been an 
advocate of formal training until recently; I would highly recommend 
taking some certification courses (zend, sun, mysql etc), and some 
formal study on the finer details of programming / architecture.


If I could do it all again I'd do both, work to get experience and 
challeges, read the great books and the manuals, and get certified 
properly at the same time.


finally, using good tools makes a vast difference, for instance I use 
eclipse + pdt + zend eclipse debugger + svn + rse + bugzilla + mylyn + 
phpdoc + phpunit (adding in ant + cruise control to the mix soon for 
continuous integration)


[snip myself]

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



Re: [PHP] while-question

2008-11-17 Thread Robert Cummings
On Mon, 2008-11-17 at 19:07 +0100, Jochem Maas wrote:
> Robert Cummings schreef:
> > On Mon, 2008-11-17 at 14:54 +, Stut wrote:
> >> On 17 Nov 2008, at 14:31, Nathan Rixham wrote:
> >>> if you really want a challenge try this one..
> >>>
> >>> task: add the numbers 5 and 17 together, using php, without using  
> >>> the + operator. fill it in:
> >>>
> >>> function add($a , $b) {
> >>> //code here but no + - / * operators
> >>> return $answer;
> >>> }
> >>>
> >>> echo add(5, 17);
> >> Elemental my dear Mr Rixham...
> > 
> > What level is that elemental?
> 
> well it's all bitwise operating ... can't get much more
> elemental that a bit in CS. but I think he meant to
> say elementary (assuming the Sherlocks Holmes catchphrase)
> 
> > 
> >> function add($a , $b)
> >> {
> >>$answer = $a ^ $b;
> >>while (0 != ($a & $b))
> >>{
> >>  $b = ($a & $b) << 1;
> >>  $answer = $answer ^ $b;
> >>}
> >>return $answer;
> >> }
> 
> nice, I think :P
> 
> > He only said you couldn't use the + operator... nothing was said about
> > using the - operator.
> 
> 
> //code here but no + - / * operators
> 

Oh... duh! :) You know what they say, if you're going to say something,
say it all in one place, not part of something in one place, and the
rest later on. Not everyone reads to the end you insensitive clod ;)

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] while-question

2008-11-17 Thread Robert Cummings
On Mon, 2008-11-17 at 10:00 -0800, bruce wrote:
> curious qiestion
> 
> to all on here who dabble in php... how many of you have actully gone to
> college, taken algorithm courses, microprocessor courses,
> design/architecture courses, etc..
> 
> or is the majority of the work here from people who've grabbed the tools and
> started programming... ?

I think it's a mixed crowd here. I have a Bachelor of Computer Science.
The various algorithms courses were some of my favourite courses in the
program along with parallel and distributed computing.

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] while-question

2008-11-17 Thread Jochem Maas
Robert Cummings schreef:
> On Mon, 2008-11-17 at 14:54 +, Stut wrote:
>> On 17 Nov 2008, at 14:31, Nathan Rixham wrote:
>>> if you really want a challenge try this one..
>>>
>>> task: add the numbers 5 and 17 together, using php, without using  
>>> the + operator. fill it in:
>>>
>>> function add($a , $b) {
>>> //code here but no + - / * operators
>>> return $answer;
>>> }
>>>
>>> echo add(5, 17);
>> Elemental my dear Mr Rixham...
> 
> What level is that elemental?

well it's all bitwise operating ... can't get much more
elemental that a bit in CS. but I think he meant to
say elementary (assuming the Sherlocks Holmes catchphrase)

> 
>> function add($a , $b)
>> {
>>$answer = $a ^ $b;
>>while (0 != ($a & $b))
>>{
>>  $b = ($a & $b) << 1;
>>  $answer = $answer ^ $b;
>>}
>>return $answer;
>> }

nice, I think :P

> He only said you couldn't use the + operator... nothing was said about
> using the - operator.


//code here but no + - / * operators




> 
> $total = -(-5 - 17);
> 
> Cheers,
> Rob.


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



RE: [PHP] while-question

2008-11-17 Thread bruce
curious qiestion

to all on here who dabble in php... how many of you have actully gone to
college, taken algorithm courses, microprocessor courses,
design/architecture courses, etc..

or is the majority of the work here from people who've grabbed the tools and
started programming... ?


-Original Message-
From: Robert Cummings [mailto:[EMAIL PROTECTED]
Sent: Monday, November 17, 2008 9:53 AM
To: Stut
Cc: Nathan Rixham; php-general@lists.php.net
Subject: Re: [PHP] while-question


On Mon, 2008-11-17 at 14:54 +, Stut wrote:
> On 17 Nov 2008, at 14:31, Nathan Rixham wrote:
> > if you really want a challenge try this one..
> >
> > task: add the numbers 5 and 17 together, using php, without using
> > the + operator. fill it in:
> >
> > function add($a , $b) {
> > //code here but no + - / * operators
> > return $answer;
> > }
> >
> > echo add(5, 17);
>
> Elemental my dear Mr Rixham...

What level is that elemental?

> function add($a , $b)
> {
>$answer = $a ^ $b;
>while (0 != ($a & $b))
>{
>  $b = ($a & $b) << 1;
>  $answer = $answer ^ $b;
>}
>return $answer;
> }

He only said you couldn't use the + operator... nothing was said about
using the - operator.

$total = -(-5 - 17);

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


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



Re: [PHP] while-question

2008-11-17 Thread Robert Cummings
On Mon, 2008-11-17 at 14:54 +, Stut wrote:
> On 17 Nov 2008, at 14:31, Nathan Rixham wrote:
> > if you really want a challenge try this one..
> >
> > task: add the numbers 5 and 17 together, using php, without using  
> > the + operator. fill it in:
> >
> > function add($a , $b) {
> > //code here but no + - / * operators
> > return $answer;
> > }
> >
> > echo add(5, 17);
> 
> Elemental my dear Mr Rixham...

What level is that elemental?

> function add($a , $b)
> {
>$answer = $a ^ $b;
>while (0 != ($a & $b))
>{
>  $b = ($a & $b) << 1;
>  $answer = $answer ^ $b;
>}
>return $answer;
> }

He only said you couldn't use the + operator... nothing was said about
using the - operator.

$total = -(-5 - 17);

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] while-question

2008-11-17 Thread Nathan Rixham

Stut wrote:

On 17 Nov 2008, at 14:31, Nathan Rixham wrote:

if you really want a challenge try this one..

task: add the numbers 5 and 17 together, using php, without using the 
+ operator. fill it in:


function add($a , $b) {
//code here but no + - / * operators
return $answer;
}

echo add(5, 17);


Elemental my dear Mr Rixham...

function add($a , $b)
{
  $answer = $a ^ $b;
  while (0 != ($a & $b))
  {
$b = ($a & $b) << 1;
$answer = $answer ^ $b;
  }
  return $answer;
}

-Stut



what an answer; very nice and indeed full marks mr stut!

now then..
echo add(5,17) . ' ' . (5 + 17) . PHP_EOL;
echo add(-5,17) . ' ' . (-5 + 17) . PHP_EOL;
echo add(5,-17) . ' ' . (5 + -17) . PHP_EOL;
echo add(-5,-17) . ' ' . (-5 + -17) . PHP_EOL;

(can you tell I've been down this route before?)

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



Re: [PHP] while-question

2008-11-17 Thread Andrew Ballard
On Mon, Nov 17, 2008 at 9:47 AM, Jochem Maas <[EMAIL PROTECTED]> wrote:
> Nathan Rixham schreef:
>> Jochem Maas wrote:
>>> $a = range(1,10);
>>> for ($i = 0, $c = count($a); $i < $c; print($a[$i]."\n"), $i++);
>>
>> think the point of this is to count the items in an array without count
>> mate :p no point in the above you could just:
>> $c = count($a);
>
> I thought the point was to avoid count() on every iteration.
> not using count() but instead looping the complete array is stupid,
> if the OP's teacher thinks count() is bad then that teacher suck's,
> count() is efficient as it can be ... it does'nt actually do a
> count when it's called merely looks up the length property of the
> array (unless I'm grossly mistaken)
>
>>
>> foreach!
>> $a = range(1,10);
>> $c = 0;
>> foreach($a as $b) {
>>  $c++;
>> }
>> echo $c. PHP_EOL;
>>
>> if you really want a challenge try this one..
>>
>> task: add the numbers 5 and 17 together, using php, without using the +
>> operator. fill it in:
>>
>> function add($a , $b) {
>>  //code here but no + - / * operators
>
> I'll assume no post/pre-increment operators either.
>
>>  return $answer;
>> }
>>
>> echo add(5, 17);
>
> function add($a, $b) {
>$a = array_merge(array_fill(0, $a, 1), array_fill(0, $b, 1));
>return count($a);
> }
>
> not very efficient :-) .. probably one of a 1000 ways to fudge it :-)
>

And another... :)

function add($a, $b) {
return array_sum(func_get_args());
}

Andrew

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



Re: [PHP] while-question

2008-11-17 Thread Stut

On 17 Nov 2008, at 14:31, Nathan Rixham wrote:

if you really want a challenge try this one..

task: add the numbers 5 and 17 together, using php, without using  
the + operator. fill it in:


function add($a , $b) {
//code here but no + - / * operators
return $answer;
}

echo add(5, 17);


Elemental my dear Mr Rixham...

function add($a , $b)
{
  $answer = $a ^ $b;
  while (0 != ($a & $b))
  {
$b = ($a & $b) << 1;
$answer = $answer ^ $b;
  }
  return $answer;
}

-Stut

--
http://stut.net/

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



Re: [PHP] while-question

2008-11-17 Thread Jochem Maas
Nathan Rixham schreef:
> Jochem Maas wrote:
>> $a = range(1,10);
>> for ($i = 0, $c = count($a); $i < $c; print($a[$i]."\n"), $i++);
> 
> think the point of this is to count the items in an array without count
> mate :p no point in the above you could just:
> $c = count($a);

I thought the point was to avoid count() on every iteration.
not using count() but instead looping the complete array is stupid,
if the OP's teacher thinks count() is bad then that teacher suck's,
count() is efficient as it can be ... it does'nt actually do a
count when it's called merely looks up the length property of the
array (unless I'm grossly mistaken)

> 
> foreach!
> $a = range(1,10);
> $c = 0;
> foreach($a as $b) {
>  $c++;
> }
> echo $c. PHP_EOL;
> 
> if you really want a challenge try this one..
> 
> task: add the numbers 5 and 17 together, using php, without using the +
> operator. fill it in:
> 
> function add($a , $b) {
>  //code here but no + - / * operators

I'll assume no post/pre-increment operators either.

>  return $answer;
> }
> 
> echo add(5, 17);

function add($a, $b) {
$a = array_merge(array_fill(0, $a, 1), array_fill(0, $b, 1));
return count($a);
}

not very efficient :-) .. probably one of a 1000 ways to fudge it :-)

> 


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



Re: [PHP] while-question

2008-11-17 Thread Nathan Rixham

Jochem Maas wrote:

$a = range(1,10);
for ($i = 0, $c = count($a); $i < $c; print($a[$i]."\n"), $i++);


think the point of this is to count the items in an array without count 
mate :p no point in the above you could just:

$c = count($a);

foreach!
$a = range(1,10);
$c = 0;
foreach($a as $b) {
 $c++;
}
echo $c. PHP_EOL;

if you really want a challenge try this one..

task: add the numbers 5 and 17 together, using php, without using the + 
operator. fill it in:


function add($a , $b) {
 //code here but no + - / * operators
 return $answer;
}

echo add(5, 17);

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



Re: [PHP] while-question

2008-11-17 Thread Jochem Maas
Timo Erbach schreef:
> ...but for best performance you should do:
> 
> 
> $counter = count($array);
> for($i = 0; $i < $counter; $i++){
>   echo $i . "\n";
> }

just for fun:

$a = range(1,10);
for ($i = 0, $c = count($a); $i < $c; print($a[$i]."\n"), $i++);

... gives an idea of the power and flexibility of a for loop
constructor, i.e. you can pretty much write a complete program
using just a for construct without even defining a loop body.

> 
> So the expression count() in the for()-loop is only
> parsed once and not every loop.
> 
> Regards
> Timo
> [snip]
> ...foreach...
> [/snip]
> 
> You could also use a for loop if you wanted to count;
> 
> for($i = 0; $i < count($array); $i++){
>   echo $i . "\n";
> }
> 
> 


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



[PHP] while-question

2008-11-17 Thread Timo Erbach

...but for best performance you should do:


$counter = count($array);
for($i = 0; $i < $counter; $i++){
  echo $i . "\n";
}

So the expression count() in the for()-loop is only
parsed once and not every loop.

Regards
Timo 


[snip]
...foreach...
[/snip]

You could also use a for loop if you wanted to count;

for($i = 0; $i < count($array); $i++){
  echo $i . "\n";
}


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



RE: [PHP] while question

2008-11-17 Thread Jay Blanchard
[snip]
...foreach...
[/snip]

You could also use a for loop if you wanted to count;

for($i = 0; $i < count($array); $i++){
   echo $i . "\n";
}



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



Re: [PHP] while question

2008-11-17 Thread Thodoris



Hi,

i'm on PHP training and our lector is telling us that to avoid counting an
array item amout thanks count($my_array), he tells we can do:
while($my_array)
{
 ... do something
}
but from experience this is an infinity loop...

it should be always something like
$count = count($my_array);
while($i <= $count)
{
...
do something
...
$i++;
}

has someone already use such syntax ? i mean as the first one.
thx.

  


Probably the easiest way for doing this is using foreach:

$a = array(1,2,3,4,5);

foreach ($a as $i) {
   print $i."";
}

This outputs:
1
2
3
4
5

This for e.g. gives an infinite loop:

$a = array(1,2,3,4,5);

while ($a) {
   print $i."";
   $i++;
}

So you are right because $a will always evaluate as true since it not 
empty. For these kinds of questions you should read the manual first and 
then ask here.


http://gr2.php.net/manual/en/control-structures.while.php

--
Thodoris


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



Re: [PHP] while question

2008-11-17 Thread Stut

On 17 Nov 2008, at 13:01, Alain Roger wrote:
i'm on PHP training and our lector is telling us that to avoid  
counting an

array item amout thanks count($my_array), he tells we can do:
while($my_array)
{
... do something
}
but from experience this is an infinity loop...

it should be always something like
$count = count($my_array);
while($i <= $count)
{
...
do something
...
$i++;
}

has someone already use such syntax ? i mean as the first one.


The while would work if you removed elements of $my_array inside the  
loop, but you would still need to be sure that it would eventually be  
empty.


I would guess that your lecturers point is that you shouldn't call  
count on every iteration as it's a waste of time. He may also be  
confusing while for foreach in which case I'd leave because you're  
unlikely to learn anything from him.


-Stut

--
http://stut.net/


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



[PHP] while question

2008-11-17 Thread Alain Roger
Hi,

i'm on PHP training and our lector is telling us that to avoid counting an
array item amout thanks count($my_array), he tells we can do:
while($my_array)
{
 ... do something
}
but from experience this is an infinity loop...

it should be always something like
$count = count($my_array);
while($i <= $count)
{
...
do something
...
$i++;
}

has someone already use such syntax ? i mean as the first one.
thx.

-- 
Alain

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


Re: [PHP] while

2008-02-23 Thread Richard Lynch
On Sat, February 23, 2008 10:16 am, Emiliano Boragina wrote:
> 
>  $buscar = $_REQUEST['buscar'];
>
>  $base = "inscripcion";
>
>  $conexion = mysql_connect ( 'localhost' , 'root' , 'root' );
>
>  mysql_select_db ( $base , $conexion );
>
>  echo "";
>
>  $resultado = mysql_query ("select * from alumnos where Curso
> like
> '$buscar'" , $conexion);

echo "Found ", mysql_num_rows($resultado), " results.\n";

>  while ( $registro = mysql_fetch_row ($resultado)) {
>
>echo "";
>
>foreach ( $registro as $clave ) {
>
> echo "" . $clave . "";
>
>}
>
>  }
>
>  echo "";
>
> ?>
>
> 
>
> 
>
> 
>
> 
>
>
>
> I want to add a message when find results on the DB: “Find n results”,
> when
> don’t find results: “0 results”.
>
> How and where I must write the IF, and how I do for the n (number of
> results) appear.


-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] while

2008-02-23 Thread Andrew Ballard
On Sat, Feb 23, 2008 at 11:16 AM, Emiliano Boragina
<[EMAIL PROTECTED]> wrote:
> Hi everyone
>
>  I am beginner
>
>  I have the following code:
>
>
>
>  
>  $buscar = $_REQUEST['buscar'];
>
>  $base = "inscripcion";
>
>  $conexion = mysql_connect ( 'localhost' , 'root' , 'root' );
>
>  mysql_select_db ( $base , $conexion );
>
>  echo "";
>
>  $resultado = mysql_query ("select * from alumnos where Curso like
>  '$buscar'" , $conexion);
>
>  while ( $registro = mysql_fetch_row ($resultado)) {
>
>echo "";
>
>foreach ( $registro as $clave ) {
>
> echo "" . $clave . "";
>
>}
>
>  }
>
>  echo "";
>
>  ?>
>
>  
>
>  
>
>  
>
>  
>
>
>
>  I want to add a message when find results on the DB: "Find n results", when
>  don't find results: "0 results".
>
>  How and where I must write the IF, and how I do for the n (number of
>  results) appear.
>
>
>
>  Thanks a lot!
>
>  Nice weekend!
>


Just get the number from mysql_num_rows($resultado). It will return
the number of rows returned by the query and you can use it anywhere
as long as $resultado is a valid resource.

http://www.php.net/mysql_num_rows



Andrew

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



[PHP] while

2008-02-23 Thread Emiliano Boragina
Hi everyone

I am beginner

I have the following code:

 

";

 $resultado = mysql_query ("select * from alumnos where Curso like
'$buscar'" , $conexion);

 while ( $registro = mysql_fetch_row ($resultado)) {

   echo "";

   foreach ( $registro as $clave ) {

echo "" . $clave . "";

   }

 }

 echo "";

?>









 

I want to add a message when find results on the DB: “Find n results”, when
don’t find results: “0 results”.

How and where I must write the IF, and how I do for the n (number of
results) appear.

 

Thanks a lot!

Nice weekend!

 

 

+  _
   // Emiliano Boragina _

   // Diseño & Comunicación //
+  _

   // [EMAIL PROTECTED]  /
   // 15 40 58 60 02 ///
+  _

 



Re: [PHP] while-do +array

2007-10-31 Thread Robin Vickery
On 31/10/2007, Steven Macintyre <[EMAIL PROTECTED]> wrote:
> Hiya,
>
> I have the following code ... which only seems to result in one item ...
> which is incorrect ... can anyone spot my problem?
>
> if ($armbase != "") {
> $options = explode(",", $armbase);
> $text .=  '';
> $get_endRow = 0;
> $get_columns = 8;
> $get_hloopRow1 = 0;
>
> do {
> if($get_endRow == 0  && $get_hloopRow1++ != 0) {
> $text .= '';
> $text .= '';
> $text .= " src='".e_BASE."images/options/armbase/".$value."'>";
> $text .= '';
> $get_endRow++;
> }
> if($get_endRow >= $get_columns) {
> $text .=  '';
> $get_endRow = 0;
> }
> } while(list($key,$value) = each($options));

The first time around the loop, both $key and $value are undefined, as
you're not setting them until the end condition.

But that's not a big deal as nothing gets done first time through the
loop except for $get_hloopRow1 getting incremented.

The next time through the loop, because $get_hloopRow1 is now not
zero, the first conditional gets executed. You add some html and the
first value from the array to $text to the string and incremenent
$get_endRow.

All subsequent times through the loop, nothing gets done because the
$get_endRow == 0 condition fails. $get_endRow never gets incrememented
again.

that help at all?

-robin

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



RE: [PHP] while-do +array

2007-10-31 Thread Robert Cummings
On Wed, 2007-10-31 at 16:20 +0200, Steven Macintyre wrote:
> > Your subject line says "while-do" + array, following code contains
> > a
> > "do-while" loop. 
> 
> Apologies :)
> 
> > We can't debug the script very well without a
> > sample
> > input since we don't know how many times the loop "should" run. To
> > debug
> > yourself, try using print_r() to see exactly what the following
> > line of
> > code produces:
> > 
> > $options = explode(",", $armbase);
> > 
> 
> Array ( [0] => 4200_side_frame.jpg [1] => 4220_integral_frame.jpg [2] =>
> flamingo_pu_armrest.jpg [3] => flexible_pu_armrest.jpg [4] =>
> futura_standard_sleigh_base.jpg [5] => futura_universal_sleigh_base.jpg )
> 
> That's the output ... so the array is definitely ok ... 

Yeah the last comment in my response detailsed your problem. Namely that
list() has no return value so the loop ends when it's return value is
checked since null juggles to false in boolean context.

Cheers,
Rob.
-- 
...
SwarmBuy.com - http://www.swarmbuy.com

Leveraging the buying power of the masses!
...

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



RE: [PHP] while-do +array

2007-10-31 Thread Steven Macintyre
> Your subject line says "while-do" + array, following code contains
> a
> "do-while" loop. 

Apologies :)

> We can't debug the script very well without a
> sample
> input since we don't know how many times the loop "should" run. To
> debug
> yourself, try using print_r() to see exactly what the following
> line of
> code produces:
> 
> $options = explode(",", $armbase);
> 

Array ( [0] => 4200_side_frame.jpg [1] => 4220_integral_frame.jpg [2] =>
flamingo_pu_armrest.jpg [3] => flexible_pu_armrest.jpg [4] =>
futura_standard_sleigh_base.jpg [5] => futura_universal_sleigh_base.jpg )

That's the output ... so the array is definitely ok ... 

s

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



Re: [PHP] while-do +array

2007-10-31 Thread Robert Cummings
On Wed, 2007-10-31 at 13:02 +0200, Steven Macintyre wrote:
> Hiya,
> 
> I have the following code ... which only seems to result in one item ...
> which is incorrect ... can anyone spot my problem?

Your subject line says "while-do" + array, following code contains a
"do-while" loop. We can't debug the script very well without a sample
input since we don't know how many times the loop "should" run. To debug
yourself, try using print_r() to see exactly what the following line of
code produces:

$options = explode(",", $armbase);

It's also useful for you to know that the list() function in your while
clause has return value void, AKA null, and so it will always be a false
statement and your loop will terminate on the first check.

Cheers,
Rob.



>   if ($armbase != "") {
>   $options = explode(",", $armbase);
>   $text .=  '';
>   $get_endRow = 0;
>   $get_columns = 8;
>   $get_hloopRow1 = 0;
> 
>   do {
>   if($get_endRow == 0  && $get_hloopRow1++ != 0) {
>   $text .= '';
>   $text .= '';
>   $text .= " src='".e_BASE."images/options/armbase/".$value."'>";
>   $text .= '';
>   $get_endRow++;
>   }
>   if($get_endRow >= $get_columns) {
>   $text .=  '';
>   $get_endRow = 0;
>   }
>   } while(list($key,$value) = each($options));
> 
>   if($get_endRow != 0) {
>   while ($get_endRow < $get_columns) {
>   $text .=  ' ';
>   $get_endRow++;
>   }
>   $text .=  '';
>   }
> 
>   $text .=  '';
> 
>   }
> 
> The purpose of the code is to create 8 colums and populate based on the
> total results returned from the while-do check
> 
> Thanks in advance
> 
> Steven
> 
-- 
...
SwarmBuy.com - http://www.swarmbuy.com

Leveraging the buying power of the masses!
...

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



[PHP] while-do +array

2007-10-31 Thread Steven Macintyre
Hiya,

I have the following code ... which only seems to result in one item ...
which is incorrect ... can anyone spot my problem?

if ($armbase != "") {
$options = explode(",", $armbase);
$text .=  '';
$get_endRow = 0;
$get_columns = 8;
$get_hloopRow1 = 0;

do {
if($get_endRow == 0  && $get_hloopRow1++ != 0) {
$text .= '';
$text .= '';
$text .= "";
$text .= '';
$get_endRow++;
}
if($get_endRow >= $get_columns) {
$text .=  '';
$get_endRow = 0;
}
} while(list($key,$value) = each($options));

if($get_endRow != 0) {
while ($get_endRow < $get_columns) {
$text .=  ' ';
$get_endRow++;
}
$text .=  '';
}

$text .=  '';

}

The purpose of the code is to create 8 colums and populate based on the
total results returned from the while-do check

Thanks in advance

Steven

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



RE: [PHP] While and echoing HTML

2005-05-10 Thread Jared Williams
> 
> I guess it is the missing semicolon.
> 
> 
> And you can write:
> 
> echo ""
> 
> as simply
> 
> echo "$product_type"
> 

I prefer 

echo '', $product_type, '';

No string concatenation, or variable replacement required.

Jared

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



Re: [PHP] While and echoing HTML

2005-05-10 Thread Burhan Khalid
Mary-Anne Nayler wrote:
Hi Mark,
As far as I can see the only problem is that you have forgotten to add a 
semicolon after the i++
Mark:
 Since you are not displaying the counter, you really don't need to 
mess with $i.

 You can reduce your code to just :
   
   $db = mysql_connect("localhost", "root", "grunger");
   mysql_select_db("status",$db);
   $result = mysql_query("SELECT ProductTypes.product_type_detail FROM
   ProductTypes",$db);
   ?>
   
   
   Product Type
   
   
   while($myrow = mysql_fetch_assoc($result))
echo "".$row['product_type']."";
   }
   ?>
   
   
   
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] While and echoing HTML

2005-05-10 Thread Richard Lynch
On Mon, May 9, 2005 10:57 pm, Mark Sargent said:
> Thanx. I saw the extra echo and removed it. Problem with that code,
> though. It displays only the 1st record, repeatedly, causing the browser
> to hang. Can anyone see what is wrong..? Cheers.

Everybody else has told you to move the $i++; inside the while { } loop.

I'm not gonna tell you that.

I'm gonna tell you to get out a pencil and some paper, and "walk" through
your code, writing down exactly what data goes where, in which variables,
on each line.

Make yourself a nice big wide columnar sheet of paper tracking each variable.

LINE | $db | $result | $myrow | $num | $i | $product_type |
1
2
3
4
5  | db-link |
6
7  || db-result |
.
.
.

You need to do this.

Trust me.

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

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



Re: [PHP] While and echoing HTML

2005-05-10 Thread Mark Sargent
Mary-Anne Nayler wrote:
oh, and the i++ should be inside the while loop and there is also a 
missing semi colon after the echo, ie;

$i=0;
while ($i < $num){
$product_type=mysql_result($result,$i,"product_type_detail");
echo "";
$i++ ;
}
Mark Sargent wrote, On 10/05/05 02:23 PM:
Hi All,
this page,
http://www.freewebmasterhelp.com/tutorials/phpmysql/5
has the below code,

$first=mysql_result($result,$i,"first");
$last=mysql_result($result,$i,"last");
$phone=mysql_result($result,$i,"phone");
$mobile=mysql_result($result,$i,"mobile");
$fax=mysql_result($result,$i,"fax");
$email=mysql_result($result,$i,"email");
$web=mysql_result($result,$i,"web");
?>





E-mail
Website



echo "";
which I basically understand, except the html generation. I am trying 
to create something similiar, although, I think there are some errors 
in even perhaps my logic..?



Jumbo Status

$db = mysql_connect("localhost", "root", "grunger");
mysql_select_db("status",$db);
$result = mysql_query("SELECT ProductTypes.product_type_detail FROM 
ProductTypes",$db);
$myrow = mysql_fetch_array($result);
$num = mysql_num_rows($result);
?>


Product Type


$i=0;
while ($i < $num){
$product_type=mysql_result($result,$i,"product_type_detail");
echo ""
}
$i++
?>




I get the folowing error,
*Parse error*: parse error, unexpected '}', expecting ',' or ';' in 
*/var/www/html/products.php* on line *20
*
which is the $i++ section.

Cheers.
Mark Sargent.

Hi All,
yes, changed it a little. Works fine now. Suprised at how much I've 
forgotten about HTML too. Cheers.

Mark Sargent.


Jumbo Status


Product Type


$db = mysql_connect("localhost", "root", "grunger");
mysql_select_db("status",$db);
$result = mysql_query("SELECT ProductTypes.product_type_detail FROM 
ProductTypes",$db);
$num = mysql_num_rows($result);
for ($i=0; $i<$num; $i++){
$myrow = mysql_fetch_array($result);
$product_type=mysql_result($result,$i,"product_type_detail");
echo "$product_type";
}
?>




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


Re: [PHP] While and echoing HTML

2005-05-10 Thread Mary-Anne Nayler
Hi Mark, 

As far as I can see the only problem is that you have forgotten to add a 
semicolon after the i++

Cheers,
Mary-Anne
Mark Sargent wrote, On 10/05/05 02:23 PM:
Hi All,
this page,
http://www.freewebmasterhelp.com/tutorials/phpmysql/5
has the below code,

$first=mysql_result($result,$i,"first");
$last=mysql_result($result,$i,"last");
$phone=mysql_result($result,$i,"phone");
$mobile=mysql_result($result,$i,"mobile");
$fax=mysql_result($result,$i,"fax");
$email=mysql_result($result,$i,"email");
$web=mysql_result($result,$i,"web");
?>





E-mail
Website



echo "";
which I basically understand, except the html generation. I am trying 
to create something similiar, although, I think there are some errors 
in even perhaps my logic..?



Jumbo Status

$db = mysql_connect("localhost", "root", "grunger");
mysql_select_db("status",$db);
$result = mysql_query("SELECT ProductTypes.product_type_detail FROM 
ProductTypes",$db);
$myrow = mysql_fetch_array($result);
$num = mysql_num_rows($result);
?>


Product Type


$i=0;
while ($i < $num){
$product_type=mysql_result($result,$i,"product_type_detail");
echo ""
}
$i++
?>




I get the folowing error,
*Parse error*: parse error, unexpected '}', expecting ',' or ';' in 
*/var/www/html/products.php* on line *20
*
which is the $i++ section.

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


Re: [PHP] While and echoing HTML

2005-05-10 Thread darren kirby
quoth the Mark Sargent:

> 
> 
> Jumbo Status
>  $db = mysql_connect("localhost", "root", "grunger");
> mysql_select_db("status",$db);
> $result = mysql_query("SELECT ProductTypes.product_type_detail FROM
> ProductTypes",$db);
> $myrow = mysql_fetch_array($result);
> $num = mysql_num_rows($result);
> ?>
> 
> 
> Product Type
> 
>  $i=0;
> while ($i < $num){
> $product_type=mysql_result($result,$i,"product_type_detail");
> echo ""

You are already in a php block here. Why the '$product_type";

> }
> $i++

As the error message is trying to tell you, php statements are terminated with 
semi-colons:

$i++;

> ?>
> 
> 
> 
>
> I get the folowing error,
>
> *Parse error*: parse error, unexpected '}', expecting ',' or ';' in
> */var/www/html/products.php* on line *20
> *
> which is the $i++ section.
>
> Cheers.
>
> Mark Sargent.

-d
-- 
darren kirby :: Part of the problem since 1976 :: http://badcomputer.org
"...the number of UNIX installations has grown to 10, with more expected..."
- Dennis Ritchie and Ken Thompson, June 1972


pgpVCEzIs6ipf.pgp
Description: PGP signature


Re: [PHP] While and echoing HTML

2005-05-10 Thread Mary-Anne Nayler
oh, and the i++ should be inside the while loop and there is also a 
missing semi colon after the echo, ie;

$i=0;
while ($i < $num){
$product_type=mysql_result($result,$i,"product_type_detail");
echo "";
$i++ ;
}
Mark Sargent wrote, On 10/05/05 02:23 PM:
Hi All,
this page,
http://www.freewebmasterhelp.com/tutorials/phpmysql/5
has the below code,

$first=mysql_result($result,$i,"first");
$last=mysql_result($result,$i,"last");
$phone=mysql_result($result,$i,"phone");
$mobile=mysql_result($result,$i,"mobile");
$fax=mysql_result($result,$i,"fax");
$email=mysql_result($result,$i,"email");
$web=mysql_result($result,$i,"web");
?>





E-mail
Website



echo "";
which I basically understand, except the html generation. I am trying 
to create something similiar, although, I think there are some errors 
in even perhaps my logic..?



Jumbo Status

$db = mysql_connect("localhost", "root", "grunger");
mysql_select_db("status",$db);
$result = mysql_query("SELECT ProductTypes.product_type_detail FROM 
ProductTypes",$db);
$myrow = mysql_fetch_array($result);
$num = mysql_num_rows($result);
?>


Product Type


$i=0;
while ($i < $num){
$product_type=mysql_result($result,$i,"product_type_detail");
echo ""
}
$i++
?>




I get the folowing error,
*Parse error*: parse error, unexpected '}', expecting ',' or ';' in 
*/var/www/html/products.php* on line *20
*
which is the $i++ section.

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


Re: [PHP] While and echoing HTML

2005-05-10 Thread Mark Sargent
Prathaban Mookiah wrote:
I guess it is the missing semicolon.
And you can write:
echo ""
as simply
echo "$product_type"
Prathap
-- Original Message ---
From: Mark Sargent <[EMAIL PROTECTED]>
To: php-general@lists.php.net
Sent: Tue, 10 May 2005 13:23:51 +0900
Subject: [PHP] While and echoing HTML
 

Hi All,
this page,
http://www.freewebmasterhelp.com/tutorials/phpmysql/5
has the below code,

$first=mysql_result($result,$i,"first");
$last=mysql_result($result,$i,"last");
$phone=mysql_result($result,$i,"phone");
$mobile=mysql_result($result,$i,"mobile");
$fax=mysql_result($result,$i,"fax");
$email=mysql_result($result,$i,"email");
$web=mysql_result($result,$i,"web");
?>


E-mail Website



echo "";
which I basically understand, except the html generation. I am 
trying to create something similiar, although, I think there are 
some errors in even perhaps my logic..?



Jumbo Status

$db = mysql_connect("localhost", "root", "grunger");
mysql_select_db("status",$db);
$result = mysql_query("SELECT ProductTypes.product_type_detail FROM 
ProductTypes",$db);
$myrow = mysql_fetch_array($result);
$num = mysql_num_rows($result);
?>


Product Type


$i=0;
while ($i < $num){
$product_type=mysql_result($result,$i,"product_type_detail");
echo ""
}
$i++
?>




I get the folowing error,
*Parse error*: parse error, unexpected '}', expecting ',' or ';' in 
*/var/www/html/products.php* on line *20
*
which is the $i++ section.

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

--- End of Original Message ---
 

Hi All,
Thanx. I saw the extra echo and removed it. Problem with that code, 
though. It displays only the 1st record, repeatedly, causing the browser 
to hang. Can anyone see what is wrong..? Cheers.

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


Re: [PHP] While and echoing HTML

2005-05-09 Thread =?iso-8859-1?q?Fabian_M=FCller?=
Mark Sargent <[EMAIL PROTECTED]> writes:

> $i=0;
> while ($i < $num){
> $product_type=mysql_result($result,$i,"product_type_detail");
> echo ""
> }
> $i++

You should put "$i++" into the while loop. And you should add an ";"
at the end of the echo line as well as at the end of "$i++".

With kind regards, Fabian Müller

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



Re: [PHP] While and echoing HTML

2005-05-09 Thread Prathaban Mookiah
I guess it is the missing semicolon.


And you can write:

echo ""

as simply

echo "$product_type"

Prathap


-- Original Message ---
From: Mark Sargent <[EMAIL PROTECTED]>
To: php-general@lists.php.net
Sent: Tue, 10 May 2005 13:23:51 +0900
Subject: [PHP] While and echoing HTML

> Hi All,
> 
> this page,
> 
> http://www.freewebmasterhelp.com/tutorials/phpmysql/5
> 
> has the below code,
> 
>  $i=0;
> while ($i < $num) {
> 
> $first=mysql_result($result,$i,"first");
> $last=mysql_result($result,$i,"last");
> $phone=mysql_result($result,$i,"phone");
> $mobile=mysql_result($result,$i,"mobile");
> $fax=mysql_result($result,$i,"fax");
> $email=mysql_result($result,$i,"email");
> $web=mysql_result($result,$i,"web");
> ?>
> 
> 
>  ".$last; ?>face="Arial, Helvetica, sans-serif"> 
> E-mail Website
> 
> 
>  $i++;
> }
> 
> echo "";
> 
> which I basically understand, except the html generation. I am 
> trying to create something similiar, although, I think there are 
> some errors in even perhaps my logic..?
> 
> 
> 
> Jumbo Status
>  $db = mysql_connect("localhost", "root", "grunger");
> mysql_select_db("status",$db);
> $result = mysql_query("SELECT ProductTypes.product_type_detail FROM 
> ProductTypes",$db);
> $myrow = mysql_fetch_array($result);
> $num = mysql_num_rows($result);
> ?>
> 
> 
> Product Type
> 
>  $i=0;
> while ($i < $num){
> $product_type=mysql_result($result,$i,"product_type_detail");
> echo ""
> }
> $i++
> ?>
> 
> 
> 
> 
> I get the folowing error,
> 
> *Parse error*: parse error, unexpected '}', expecting ',' or ';' in 
> */var/www/html/products.php* on line *20
> *
> which is the $i++ section.
> 
> Cheers.
> 
> Mark Sargent.
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
--- End of Original Message ---

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



[PHP] While and echoing HTML

2005-05-09 Thread Mark Sargent
Hi All,
this page,
http://www.freewebmasterhelp.com/tutorials/phpmysql/5
has the below code,

$first=mysql_result($result,$i,"first");
$last=mysql_result($result,$i,"last");
$phone=mysql_result($result,$i,"phone");
$mobile=mysql_result($result,$i,"mobile");
$fax=mysql_result($result,$i,"fax");
$email=mysql_result($result,$i,"email");
$web=mysql_result($result,$i,"web");
?>





E-mail
Website



echo "";
which I basically understand, except the html generation. I am trying to 
create something similiar, although, I think there are some errors in 
even perhaps my logic..?



Jumbo Status

$db = mysql_connect("localhost", "root", "grunger");
mysql_select_db("status",$db);
$result = mysql_query("SELECT ProductTypes.product_type_detail FROM 
ProductTypes",$db);
$myrow = mysql_fetch_array($result);
$num = mysql_num_rows($result);
?>


Product Type


$i=0;
while ($i < $num){
$product_type=mysql_result($result,$i,"product_type_detail");
echo ""
}
$i++
?>




I get the folowing error,
*Parse error*: parse error, unexpected '}', expecting ',' or ';' in 
*/var/www/html/products.php* on line *20
*
which is the $i++ section.

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


Re: [PHP] while loop

2005-02-23 Thread Jochem Maas
Reinhart Viane wrote:
Well I'm able to do that, there are only 4 different types, but the 4
queries have exactly the same syntax so I think it's better to combine them.
Not? 
what about using UNION on the four queries?
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] while loop

2005-02-23 Thread Marek Kilimajer
Reinhart Viane wrote:
Well I'm able to do that, there are only 4 different types, but the 4
queries have exactly the same syntax so I think it's better to combine them.
Not? 
Since mysql 4.1 you can use GROUP_CONCAT() function:
SELECT Act_date, Act_type_id,
LEFT( GROUP_CONCAT(Act_name
   ORDER BY Act_date
   SEPARATOR '|'),
  129 ) as Act_names
FROM activities GROUP BY Act_date, Act_type_id;
Act_names will be string containing the names separated by |
129 is the maximum size of Act_name * 2 + 1 for the separator.
-Oorspronkelijk bericht-
Van: Justin Lilly [mailto:[EMAIL PROTECTED] 
Verzonden: woensdag 23 februari 2005 18:57
Aan: php-general@lists.php.net
Onderwerp: Re: [PHP] while loop

Perhaps it is just me, but wouldn't it be easier to make individual
mysql queries for each different act type? That would make the sorting
-much- easier. I'm not sure if that's an option, but if it is, I'd
consider exploring it.
select * from activities where act_date >= NOW() && act_type_id = 1
or something of that nature.
-justin
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP] while loop

2005-02-23 Thread Reinhart Viane
Well I'm able to do that, there are only 4 different types, but the 4
queries have exactly the same syntax so I think it's better to combine them.
Not? 

-Oorspronkelijk bericht-
Van: Justin Lilly [mailto:[EMAIL PROTECTED] 
Verzonden: woensdag 23 februari 2005 18:57
Aan: php-general@lists.php.net
Onderwerp: Re: [PHP] while loop

Perhaps it is just me, but wouldn't it be easier to make individual
mysql queries for each different act type? That would make the sorting
-much- easier. I'm not sure if that's an option, but if it is, I'd
consider exploring it.

select * from activities where act_date >= NOW() && act_type_id = 1

or something of that nature.

-justin


On Wed, 23 Feb 2005 13:05:53 +0100, Reinhart Viane <[EMAIL PROTECTED]> wrote:
> 
> 
> Hey list
> 
>  
> 
> I have a mysql table like this:
> 
>  
> 
> Act_name   Act_type_id  Act_date
> 
> Heyhey 1  22-06-05
> 
> Aloha2  22-06-05
> 
> Tralala   2  22-06-05
> 
> Wuhu1  22-06-05
> 
> Hehe 3  22-06-05
> 
> Olalal3  22-06-05
> 
> Pompom   1  22-06-05
> 
> Wuhu2  22-06-05
> 
>  
> 
> Now I retrieve all activities happening in the future with this query:
> 
> $sqlact="select * from activities where act_date >= NOW() order by
> act_type_id";
> 
> $getact=mysql_query($sqlact)
> 
>  
> 
> What I'm trying to do now is:
> 
> From the result array, pick from every different act_type_id the two
> activities that will happen first and put them in 2 variables 
> 
> Eg. 
> 
> The two act_date with act_type_id 1
> 
> Should be stored in 
> 
> $Act1result1 and $act1result2
> 
>  
> 
> The two act_date with act_type_id 2
> 
> Should be stored in 
> 
> $Act2result1 and $act2result2
> 
>  
> 
> I think this can be done with a loop in a loop but I always manage to
create
> some errors causing my apache to crash (infinite loop I suppose)
> 
> Can someone help me on this?
> 
>  
> 
> Thx in advance
> 
>  
> 
> Reinhart
> 
>  
> No virus found in this outgoing message.
> Checked by AVG Anti-Virus.
> Version: 7.0.300 / Virus Database: 266.4.0 - Release Date: 22/02/2005
> 
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 


-- 
Justin Lilly
University of South Carolina

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




-- 
No virus found in this incoming message.
Checked by AVG Anti-Virus.
Version: 7.0.300 / Virus Database: 266.4.0 - Release Date: 22/02/2005




-- 
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.300 / Virus Database: 266.4.0 - Release Date: 22/02/2005

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



Re: [PHP] while loop

2005-02-23 Thread Justin Lilly
Perhaps it is just me, but wouldn't it be easier to make individual
mysql queries for each different act type? That would make the sorting
-much- easier. I'm not sure if that's an option, but if it is, I'd
consider exploring it.

select * from activities where act_date >= NOW() && act_type_id = 1

or something of that nature.

-justin


On Wed, 23 Feb 2005 13:05:53 +0100, Reinhart Viane <[EMAIL PROTECTED]> wrote:
> 
> 
> Hey list
> 
>  
> 
> I have a mysql table like this:
> 
>  
> 
> Act_name   Act_type_id  Act_date
> 
> Heyhey 1  22-06-05
> 
> Aloha2  22-06-05
> 
> Tralala   2  22-06-05
> 
> Wuhu1  22-06-05
> 
> Hehe 3  22-06-05
> 
> Olalal3  22-06-05
> 
> Pompom   1  22-06-05
> 
> Wuhu2  22-06-05
> 
>  
> 
> Now I retrieve all activities happening in the future with this query:
> 
> $sqlact="select * from activities where act_date >= NOW() order by
> act_type_id";
> 
> $getact=mysql_query($sqlact)
> 
>  
> 
> What I'm trying to do now is:
> 
> From the result array, pick from every different act_type_id the two
> activities that will happen first and put them in 2 variables 
> 
> Eg. 
> 
> The two act_date with act_type_id 1
> 
> Should be stored in 
> 
> $Act1result1 and $act1result2
> 
>  
> 
> The two act_date with act_type_id 2
> 
> Should be stored in 
> 
> $Act2result1 and $act2result2
> 
>  
> 
> I think this can be done with a loop in a loop but I always manage to create
> some errors causing my apache to crash (infinite loop I suppose)
> 
> Can someone help me on this?
> 
>  
> 
> Thx in advance
> 
>  
> 
> Reinhart
> 
>  
> No virus found in this outgoing message.
> Checked by AVG Anti-Virus.
> Version: 7.0.300 / Virus Database: 266.4.0 - Release Date: 22/02/2005
> 
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 


-- 
Justin Lilly
University of South Carolina

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



Re: [PHP] while loop

2005-02-23 Thread Richard Lynch
Reinhart Viane wrote:
> Hey list
>
> I have a mysql table like this:
>
> Act_name   Act_type_id  Act_date
>
> Heyhey 1  22-06-05
>
> Aloha2  22-06-05
>
> Tralala   2  22-06-05
>
> Wuhu1  22-06-05
>
> Hehe 3  22-06-05
>
> Olalal3  22-06-05
>
> Pompom   1  22-06-05
>
> Wuhu2  22-06-05
>
> Now I retrieve all activities happening in the future with this query:
>
> $sqlact="select * from activities where act_date >= NOW() order by
> act_type_id";
>
> $getact=mysql_query($sqlact)
>
> What I'm trying to do now is:
>
> From the result array, pick from every different act_type_id the two
> activities that will happen first and put them in 2 variables

Change your "ORDER BY" to : "order by Act_date"

That's the only way you're gonna get them in date order to get the NEXT
two in time.

Then you need to get just two of each kind, which SQL isn't really geared
to do, at least not easily.

Hopefully, you'll never have, like, *THOUSANDS* of upcoming Acts...

$next_two = array();
while (list($name, $type, $date) = mysql_fetch_row($getact)){
  if (!isset($next_two[$type]) || count($next_two[$type]) < 2){
$new_two[$type][] = "$name $date";
  }
}

You now have an array $new_two with indices of the Act's type, and values
of arrays of at most 2 entries, with "$name $date".

If you need $name and $date separated, you could use: array($name, $date)
instead of "$name $date" inside the loop.

You'll need to use some kind of loop to go through the $next_two array.

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

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



Re: [PHP] while loop

2005-02-23 Thread Burhan Khalid
Reinhart Viane wrote:
Hey list
 

I have a mysql table like this:
[ snipped ]
 

Now I retrieve all activities happening in the future with this query:
$sqlact="select * from activities where act_date >= NOW() order by 
act_type_id”;

$getact=mysql_query($sqlact)
 

What I’m trying to do now is:
 From the result array, pick from every different act_type_id the two 
activities that will happen first and put them in 2 variables
while($row = mysql_fetch_assoc($getact))
{
  $results[$row['act_type_id']][] = $row;
}
echo ""; print_r($results); echo "";
Please send only plain text messages to the list, and avoid attachments.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] while loop

2005-02-23 Thread Reinhart Viane








Hey list

 

I have a mysql table like this:

 

Act_name  
Act_type_id  Act_date

Heyhey
   
1 
22-06-05

Aloha   
   
2 
22-06-05

Tralala  
   
2 
22-06-05

Wuhu   
    1 
22-06-05

Hehe
   
3 
22-06-05

Olalal   
   
3 
22-06-05

Pompom  
1 
22-06-05

Wuhu   
    2 
22-06-05

 

Now I retrieve all activities happening in the future with
this query:

$sqlact="select * from activities where act_date >=
NOW() order by act_type_id”;

$getact=mysql_query($sqlact)

 

What I’m trying to do now is:

From the result array, pick from every different act_type_id
the two activities that will happen first and put them in 2 variables 

Eg. 

The two act_date with act_type_id 1

Should be stored in 

$Act1result1 and $act1result2

 

The two act_date with act_type_id 2

Should be stored in 

$Act2result1 and $act2result2

 

I think this can be done with a loop in a loop but I always
manage to create some errors causing my apache to crash (infinite loop I suppose)

Can someone help me on this?

 

Thx in advance

 

Reinhart

 






No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.300 / Virus Database: 266.4.0 - Release Date: 22/02/2005

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

Re: [PHP] while inside a function

2004-12-05 Thread Louie Miranda
sorry, i overlooked on something.

i need to rest for a while, im working on a wrong program thats why it
wont work.
heh, :(. thanks again.

-- 
Louie Miranda
http://www.axishift.com

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



Re: [PHP] while inside a function

2004-12-05 Thread Raditha Dissanayake
Louie Miranda wrote:
i have a while statement inside a function, but it seems like it dont
work. is this possible?
 

Add the following lines:
global $apo;
global $row;
This will make it work for you but it's not the best solution. It's 
better to pass in parameters to the function rather than to rely on globals.


function hello() {
while ($apo->fetchInto($row)) {
print "hello 2";
}
}; /eof

 


--
Raditha Dissanayake.
--
http://www.radinks.com/print/card-designer/ | Card Designer Applet
http://www.radinks.com/upload/  | Drag and Drop Upload 

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


[PHP] while inside a function

2004-12-05 Thread Louie Miranda
i have a while statement inside a function, but it seems like it dont
work. is this possible?

function hello() {

while ($apo->fetchInto($row)) {
print "hello 2";
}
}; /eof



-- 
Louie Miranda
http://www.axishift.com

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



Re: [PHP] while inside a while or join or...

2004-05-16 Thread John W. Holmes
T. H. Grejc wrote:
Hallo,
I know of a few ways of doing this but I am not sure that any is right. 
I want to consult with you what is the best way of doing this:

Table 1:
++-+
| *a* | *b* |
++-+
|  2   |  1|
++-+
|  2   |  2|
++-+
Table 2:
++-+
| *b* | *d* |
++-+
|  1   |  asd |
++-+
|  2   |  fgh |
++-+
I would like to select all 'b' from Table_1 WHERE a = '2' and then to 
select all 'd' from table_2 with 'b' from previous result.

Table 2 is the Table with UserNames (d) and Table 1 is the table with 
'marked' UserID's (b).
What's this go to do with PHP? This should be on php-db at least...
SELECT t1.b, t2.d FROM table1 t1, table2, t2 WHERE t1.a = 2 AND t1.b = t2.b
--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals – www.phparch.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] while inside a while or join or...

2004-05-16 Thread Curt Zirzow
* Thus wrote T. H. Grejc ([EMAIL PROTECTED]):
> Hallo,
> 
> I know of a few ways of doing this but I am not sure that any is right. 
> I want to consult with you what is the best way of doing this:
> 
> ...
> 
> I would like to select all 'b' from Table_1 WHERE a = '2' and then to 
> select all 'd' from table_2 with 'b' from previous result.
> 
> Table 2 is the Table with UserNames (d) and Table 1 is the table with 
> 'marked' UserID's (b).
> 
> What is the best way of doing this.

I'm having difficluties finding out how this is related to php, but
anyway... this is a  simple joining of two tables.

so you have

  select b from table_1 where a = 2

and
  select d from table_2 where b = results from table_1

Thus

  select table_1.b, table_2.d from table_1, table_2 
   where table_1.b = table_2.b 
and table_1.a = 2


come to think of it, thats very much like an algebra problem.


Curt
-- 
"I used to think I was indecisive, but now I'm not so sure."

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



Re: [PHP] while inside a while or join or...

2004-05-16 Thread Rachel Rodriguez

> 
> I would like to select all 'b' from Table_1 WHERE a
> = '2' and then to 
> select all 'd' from table_2 with 'b' from previous
> result.
> 
> Table 2 is the Table with UserNames (d) and Table 1
> is the table with 
> 'marked' UserID's (b).
> 
If I understand you correctly, its sounds like you
want to do the following:

$sql = "
SELECT t1.b,
   t2.d
FROM Table_1 AS t1
LEFT JOIN Table_2 AS t2
ON (t1.b = t2.d)
WHERE t1.a = '2'";


=
~Rachel




__
Do you Yahoo!?
SBC Yahoo! - Internet access at a great low price.
http://promo.yahoo.com/sbc/

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



[PHP] while inside a while or join or...

2004-05-16 Thread T. H. Grejc
Hallo,
I know of a few ways of doing this but I am not sure that any is right. 
I want to consult with you what is the best way of doing this:

Table 1:
++-+
| *a* | *b* |
++-+
|  2   |  1|
++-+
|  2   |  2|
++-+
Table 2:
++-+
| *b* | *d* |
++-+
|  1   |  asd |
++-+
|  2   |  fgh |
++-+
I would like to select all 'b' from Table_1 WHERE a = '2' and then to 
select all 'd' from table_2 with 'b' from previous result.

Table 2 is the Table with UserNames (d) and Table 1 is the table with 
'marked' UserID's (b).

What is the best way of doing this.
TNX
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] 'while' not picking up on first DB record

2003-09-17 Thread Miles Thompson
Please don't cross-post.
See below - M.
At 10:17 AM 9/17/2003 -0400, Roger Spears wrote:
Hello,

Can anyone from the lists please tell me why this bit of code is not 
picking up on the first record in the database?  If the 'id' I'm looking 
for is '1' it doesn't populate the _SESSION variables.  Any 'id' greater 
then '1' will populate the _SESSION variables.

$q = "SELECT * FROM employee";
$r = mysql_query($q);
You're picking up first line here, but doing nothing with it.

$row = mysql_fetch_array($r);
So delete it or comment it out.


while ($row = mysql_fetch_array($r))
 {
   if ($employee == $row["id"])
   {
   $_SESSION['dear'] = $row["last_name"];
   $_SESSION['to_email'] = $row["email"];
   }
 }
Thanks,
Roger
--
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


  1   2   >