Re: [PHP] Why is this code hanging?
On Tuesday 02 July 2002 16:31, Leif K-Brooks wrote: > I am trying to make a simple php program to produce text lIkE tHiS. > The thing is, it hangs for a while andd then says it's reached the > maximum execution time of 30 seconds. The error is on line 18. Any > ideas? My code: > print ""; > if(!isset($_POST['text'])){ > print <<< END [snip] I know your question has already been answered, but in future please indicate which is line X. I for one would not count the lines to see which one is line 18. Make it easy for people to help you. -- Jason Wong -> Gremlins Associates -> www.gremlins.com.hk Open Source Software Systems Integrators * Web Design & Hosting * Internet & Intranet Applications Development * /* Question: Is it better to abide by the rules until they're changed or help speed the change by breaking them? */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Why is this code hanging?
Leif, I think you are missing a $count++ somewhere. Its a mistake I commonly make... HTH Chris Leif K-Brooks wrote: > I am trying to make a simple php program to produce text lIkE tHiS. > The thing is, it hangs for a while andd then says it's reached the > maximum execution time of 30 seconds. The error is on line 18. Any > ideas? My code: > print ""; > if(!isset($_POST['text'])){ > print <<< END > > Text: > > END; > }else{ > $text = $_POST['text']; > $last = false; > $final = ""; > $count = 0; > while($count < strlen($text)){ > $this = $text{$count}; > if(ereg("[a-zA-Z]",$this)){ > if($last){ > $final = $final.strtolower($this); > $last = false; > }else{ > $final = $final.strtoupper($this); > $last = true; > } > } > } > print $final; > } > print ""; > ?> > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Why is this code hanging?
Oops, sorry for the dumb problem... John Holmes wrote: >You're not incrementing $count within your while loop. So it's staying >at zero the whole time... > >---John Holmes... > > > >>-Original Message- >>From: Leif K-Brooks [mailto:[EMAIL PROTECTED]] >>Sent: Tuesday, July 02, 2002 4:31 AM >>To: [EMAIL PROTECTED] >>Subject: [PHP] Why is this code hanging? >> >>I am trying to make a simple php program to produce text lIkE tHiS. >> The thing is, it hangs for a while andd then says it's reached the >>maximum execution time of 30 seconds. The error is on line 18. Any >>ideas? My code: >>>print ""; >>if(!isset($_POST['text'])){ >>print <<< END >> >>Text: >> >>END; >>}else{ >>$text = $_POST['text']; >>$last = false; >>$final = ""; >>$count = 0; >>while($count < strlen($text)){ >>$this = $text{$count}; >>if(ereg("[a-zA-Z]",$this)){ >>if($last){ >>$final = $final.strtolower($this); >>$last = false; >>}else{ >>$final = $final.strtoupper($this); >>$last = true; >>} >>} >>} >>print $final; >>} >>print ""; >>?> >> >> >>-- >>PHP General Mailing List (http://www.php.net/) >>To unsubscribe, visit: http://www.php.net/unsub.php >> >> > > > > >
RE: [PHP] Why is this code hanging?
You're not incrementing $count within your while loop. So it's staying at zero the whole time... ---John Holmes... > -Original Message- > From: Leif K-Brooks [mailto:[EMAIL PROTECTED]] > Sent: Tuesday, July 02, 2002 4:31 AM > To: [EMAIL PROTECTED] > Subject: [PHP] Why is this code hanging? > > I am trying to make a simple php program to produce text lIkE tHiS. > The thing is, it hangs for a while andd then says it's reached the > maximum execution time of 30 seconds. The error is on line 18. Any > ideas? My code: > print ""; > if(!isset($_POST['text'])){ > print <<< END > > Text: > > END; > }else{ > $text = $_POST['text']; > $last = false; > $final = ""; > $count = 0; > while($count < strlen($text)){ > $this = $text{$count}; > if(ereg("[a-zA-Z]",$this)){ > if($last){ > $final = $final.strtolower($this); > $last = false; > }else{ > $final = $final.strtoupper($this); > $last = true; > } > } > } > print $final; > } > print ""; > ?> > > > -- > 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
[PHP] Why is this code hanging?
I am trying to make a simple php program to produce text lIkE tHiS. The thing is, it hangs for a while andd then says it's reached the maximum execution time of 30 seconds. The error is on line 18. Any ideas? My code: "; if(!isset($_POST['text'])){ print <<< END Text: END; }else{ $text = $_POST['text']; $last = false; $final = ""; $count = 0; while($count < strlen($text)){ $this = $text{$count}; if(ereg("[a-zA-Z]",$this)){ if($last){ $final = $final.strtolower($this); $last = false; }else{ $final = $final.strtoupper($this); $last = true; } } } print $final; } print ""; ?> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php