Re: [PHP-DB] Re: [PHP] Problems w/ goto

2010-12-20 Thread Daniel Brown
On Sat, Dec 18, 2010 at 17:02, David Hutto smokefl...@gmail.com wrote:
 or maybe it's saturday morning and i'm drunk?

This seems to be the most likely, and considering how all messages
are permanently and independently archived and propagate throughout
the Internet, it might be a good reason not to go nuts in sending
unrelated and unintelligible messages of this nature in the future.

-- 
/Daniel P. Brown
Network Infrastructure Manager
Documentation, Webmaster Teams
http://www.php.net/

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



Re: [PHP-DB] Re: [PHP] Problems w/ goto

2010-12-20 Thread David Hutto
On Mon, Dec 20, 2010 at 7:37 AM, Daniel Brown danbr...@php.net wrote:
 On Sat, Dec 18, 2010 at 17:02, David Hutto smokefl...@gmail.com wrote:
 or maybe it's saturday morning and i'm drunk?

    This seems to be the most likely, and considering how all messages
 are permanently and independently archived and propagate throughout
 the Internet, it might be a good reason not to go nuts in sending
 unrelated and unintelligible messages of this nature in the future.

Yeah, that hindsights 20/20 ain't it?


 --
 /Daniel P. Brown
 Network Infrastructure Manager
 Documentation, Webmaster Teams
 http://www.php.net/




-- 
They're installing the breathalyzer on my email account next week.

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



[PHP-DB] RE: [PHP] Problems w/ goto

2010-12-18 Thread Geoffrey Bernardo Van Wyk
Ethan,
 
I tried to test your code, but I get this error next to the labels and goto
statements:
 
Language feature not compatible with PHP version indicated in project
settings
 
I have PHP 5.3.0.
 
Geoffrey

  _  

From: Ethan Rosenberg [mailto:eth...@earthlink.net] 
Sent: 17 December 2010 06:39 PM
To: php-db-lists.php.net; php-gene...@lists.php.net
Subject: [PHP] Problems w/ goto



Dear List - 

I am sending this again since it does not seem to have posted. 

Ethan 
+++ 
Dear List - 

Thank you with your excellent help in the past.  Here is another puzzler


I am trying to write a program that can have two(2) independent forms 
in one PHP file.  When I run the code below [from PHP - A Beginner's 
Guide], to which I have added a second form, it freezes.  Without the 
goto statements, it runs.  When it does run, it displays both forms 
on one Web screen. What I desire is for the first form to be 
displayed, the data entered and then the second form displayed.  In 
an actual, not test program like this one, the data in the second 
form would be dependent on the first form. 

What did I do wrong? 

Thanks in advance. 

Here is the code: 

 
!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN 
DTD/xhtml1-transitional.dtd 
html xmlns=http://www.w3.org/1999/xhtml; xml:lang=en lang=en 
   head 
 titleProject 4-4: Age Calculator/title 
   /head 
   body 
 h2Project 4-4: Age Calculator/h2 
?php 
 // if form not yet submitted 
 // display form 

$ender = 0; 
begin: 

 if($ender == 1) 
 exit(); 
 if (!isset($_POST['dob'])) 
 { 
start1: 

echo   form method=\post\ action=\agecalc2.php\; 
echo   Enter your date of birth, in mm/dd/ format: br /; 
echo   input type=\text\ name=\dob\ /; 
echo   p; 
echo   input type=\submit\ name=\submit\ value=\Submit\ /; 
echo   /form; 

goto begin; 
 // if form submitted 
 // process form input 
 } 
else 
 { 
starter: 
if (isset($_POST['cat'])) 
 goto purr; 
   // split date value into components 
   $dateArr = explode('/', $_POST['dob']); 

   // calculate timestamp corresponding to date value 
   $dateTs = strtotime($_POST['dob']); 

   // calculate timestamp corresponding to 'today' 
   $now = strtotime('today'); 

   // check that the value entered is in the correct format 
   if (sizeof($dateArr) != 3) { 
 die('ERROR: Please enter a valid date of birth'); 
   } 

   // check that the value entered is a valid date 
   if (!checkdate($dateArr[0], $dateArr[1], $dateArr[2])) { 
 die('ERROR: Please enter a valid date of birth'); 
   } 

   // check that the date entered is earlier than 'today' 
   if ($dateTs = $now) { 
 die('ERROR: Please enter a date of birth earlier than today'); 
   } 

   // calculate difference between date of birth and today in days 
   // convert to years 
   // convert remaining days to months 
   // print output 
   $ageDays = floor(($now - $dateTs) / 86400); 
   $ageYears = floor($ageDays / 365); 
   $ageMonths = floor(($ageDays - ($ageYears * 365)) / 30); 
   echo You are approximately $ageYears years and $ageMonths months
old.; 
   goto meow; 
  } 

meow: 
 if (!isset($_POST['dob'])) 
 goto begin; 
 if (!isset($_POST['cat'])) 
 { 


echo   form method=\post\ action=\agecalc2.php\; 
echo   br /br /Enter your kitten's name: br /; 
echo   input type=\text\ name=\cat\ /; 
echo   p; 
echo   input type=\submit\ name=\submit\ value=\Submit 
Kitten\ /; 
echo /form; 

} 
else 
{ 
purr: 
 $name_cat = $_POST['cat']; 

 echo Your Kitten is $name_cat; 
 $ender = 1; 
} 
if ($ender == 0) 
 goto begin; 
first_step: 
? 

   /body 
/html 

 

Ethan 

MySQL 5.1  PHP 5  Linux [Debian (sid)]  



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

  _  

No virus found in this message.
Checked by AVG - www.avg.com
Version: 10.0.1170 / Virus Database: 1435/3323 - Release Date: 12/18/10



[PHP-DB] Re: [PHP] Problems w/ goto

2010-12-18 Thread David Hutto
On Sat, Dec 18, 2010 at 12:45 PM, Geoffrey Bernardo Van Wyk
geoffrey.van@gmail.com wrote:
 Ethan,

 I tried to test your code, but I get this error next to the labels and goto
 statements:

As a 'professional' programmer, working for an entity, we deal with
these problems as we go.  As novices, we deal with it on a daily
basis. As computer scientists, we think of it as a problem already
solved, but in need of translation. Understand, buddy pal.



 Language feature not compatible with PHP version indicated in project
 settings

 I have PHP 5.3.0.

 Geoffrey

  _

 From: Ethan Rosenberg [mailto:eth...@earthlink.net]
 Sent: 17 December 2010 06:39 PM
 To: php-db-lists.php.net; php-gene...@lists.php.net
 Subject: [PHP] Problems w/ goto



 Dear List -

 I am sending this again since it does not seem to have posted.

 Ethan
 +++
 Dear List -

 Thank you with your excellent help in the past.  Here is another puzzler


 I am trying to write a program that can have two(2) independent forms
 in one PHP file.  When I run the code below [from PHP - A Beginner's
 Guide], to which I have added a second form, it freezes.  Without the
 goto statements, it runs.  When it does run, it displays both forms
 on one Web screen. What I desire is for the first form to be
 displayed, the data entered and then the second form displayed.  In
 an actual, not test program like this one, the data in the second
 form would be dependent on the first form.

 What did I do wrong?

 Thanks in advance.

 Here is the code:

 
 !DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN
    DTD/xhtml1-transitional.dtd
 html xmlns=http://www.w3.org/1999/xhtml; xml:lang=en lang=en
   head
     titleProject 4-4: Age Calculator/title
   /head
   body
     h2Project 4-4: Age Calculator/h2
 ?php
     // if form not yet submitted
     // display form

 $ender = 0;
 begin:

         if($ender == 1)
                 exit();
     if (!isset($_POST['dob']))
     {
 start1:

 echo   form method=\post\ action=\agecalc2.php\;
 echo   Enter your date of birth, in mm/dd/ format: br /;
 echo   input type=\text\ name=\dob\ /;
 echo       p;
 echo   input type=\submit\ name=\submit\ value=\Submit\ /;
 echo   /form;

 goto begin;
     // if form submitted
     // process form input
     }
 else
     {
 starter:
 if (isset($_POST['cat']))
         goto purr;
       // split date value into components
       $dateArr = explode('/', $_POST['dob']);

       // calculate timestamp corresponding to date value
       $dateTs = strtotime($_POST['dob']);

       // calculate timestamp corresponding to 'today'
       $now = strtotime('today');

       // check that the value entered is in the correct format
       if (sizeof($dateArr) != 3) {
         die('ERROR: Please enter a valid date of birth');
       }

       // check that the value entered is a valid date
       if (!checkdate($dateArr[0], $dateArr[1], $dateArr[2])) {
         die('ERROR: Please enter a valid date of birth');
       }

       // check that the date entered is earlier than 'today'
       if ($dateTs = $now) {
         die('ERROR: Please enter a date of birth earlier than today');
       }

       // calculate difference between date of birth and today in days
       // convert to years
       // convert remaining days to months
       // print output
       $ageDays = floor(($now - $dateTs) / 86400);
       $ageYears = floor($ageDays / 365);
       $ageMonths = floor(($ageDays - ($ageYears * 365)) / 30);
       echo You are approximately $ageYears years and $ageMonths months
 old.;
       goto meow;
  }

 meow:
         if (!isset($_POST['dob']))
                 goto begin;
     if (!isset($_POST['cat']))
     {


 echo   form method=\post\ action=\agecalc2.php\;
 echo   br /br /Enter your kitten's name: br /;
 echo   input type=\text\ name=\cat\ /;
 echo   p;
 echo       input type=\submit\ name=\submit\ value=\Submit
 Kitten\ /;
 echo     /form;

 }
 else
 {
 purr:
         $name_cat = $_POST['cat'];

         echo Your Kitten is $name_cat;
         $ender = 1;
 }
 if ($ender == 0)
         goto begin;
 first_step:
 ?

   /body
 /html

 

 Ethan

 MySQL 5.1  PHP 5  Linux [Debian (sid)]



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

  _

 No virus found in this message.
 Checked by AVG - www.avg.com
 Version: 10.0.1170 / Virus Database: 1435/3323 - Release Date: 12/18/10



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



[PHP-DB] Re: [PHP] Problems w/ goto

2010-12-18 Thread David Hutto
You approved all of us, no matter the  peer review, when you signed up
or the list. The accumulation of knowledge,
is insurmountable when delivered as a whole, but devourable if you
need satiation of appetite.

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



[PHP-DB] Re: [PHP] Problems w/ goto

2010-12-18 Thread David Hutto
or maybe it's saturday morning and i'm drunk?

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



[PHP-DB] Re: [PHP] Problems w/ goto

2010-12-18 Thread David Hutto
check out my new sig.

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



[PHP-DB] RE: [PHP] Problems w/ goto

2010-12-17 Thread Jay Blanchard
[snip]
Thank you with your excellent help in the past.  Here is another
puzzler

I am trying to write a program that can have two(2) independent forms 
in one PHP file.  When I run the code below [from PHP - A Beginner's 
Guide], to which I have added a second form, it freezes.  Without the 
goto statements, it runs.  When it does run, it displays both forms 
on one Web screen. What I desire is for the first form to be 
displayed, the data entered and then the second form displayed.  In 
an actual, not test program like this one, the data in the second 
form would be dependent on the first form.

What did I do wrong?
[/snip]

You used GOTO. 

In this case I would recommend using something like jQuery to 'hide' one
form until the other form is complete. PHP has sent the output to the
browser already, both forms are there and display when you remove the
GOTO. 

GOTO should never be used like this.

GOTO should never be used.

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



[PHP-DB] RE: [PHP] Problems w/ goto

2010-12-17 Thread Steve Staples
On Fri, 2010-12-17 at 10:50 -0600, Jay Blanchard wrote:
 [snip]
 Thank you with your excellent help in the past.  Here is another
 puzzler
 
 I am trying to write a program that can have two(2) independent forms 
 in one PHP file.  When I run the code below [from PHP - A Beginner's 
 Guide], to which I have added a second form, it freezes.  Without the 
 goto statements, it runs.  When it does run, it displays both forms 
 on one Web screen. What I desire is for the first form to be 
 displayed, the data entered and then the second form displayed.  In 
 an actual, not test program like this one, the data in the second 
 form would be dependent on the first form.
 
 What did I do wrong?
 [/snip]
 
 You used GOTO. 
 
 In this case I would recommend using something like jQuery to 'hide' one
 form until the other form is complete. PHP has sent the output to the
 browser already, both forms are there and display when you remove the
 GOTO. 
 
 GOTO should never be used like this.
 
 GOTO should never be used.
 

Wow... that brought me back to 1990... using basic and batch files...
I honestly didn't even know that the GOTO was still in existence,
especially within PHP.

I had to show the people in my office, and we all got a chuckle from teh
XKCD comic in the PHP documentation for GOTO
http://ca2.php.net/goto

Steve


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



[PHP-DB] Re: [PHP] Problems w/ goto

2010-12-17 Thread Richard Quadling
On 17 December 2010 17:08, Steve Staples sstap...@mnsi.net wrote:
 On Fri, 2010-12-17 at 10:50 -0600, Jay Blanchard wrote:
 [snip]
 Thank you with your excellent help in the past.  Here is another
 puzzler

 I am trying to write a program that can have two(2) independent forms
 in one PHP file.  When I run the code below [from PHP - A Beginner's
 Guide], to which I have added a second form, it freezes.  Without the
 goto statements, it runs.  When it does run, it displays both forms
 on one Web screen. What I desire is for the first form to be
 displayed, the data entered and then the second form displayed.  In
 an actual, not test program like this one, the data in the second
 form would be dependent on the first form.

 What did I do wrong?
 [/snip]

 You used GOTO.

 In this case I would recommend using something like jQuery to 'hide' one
 form until the other form is complete. PHP has sent the output to the
 browser already, both forms are there and display when you remove the
 GOTO.

 GOTO should never be used like this.

 GOTO should never be used.


 Wow... that brought me back to 1990... using basic and batch files...
 I honestly didn't even know that the GOTO was still in existence,
 especially within PHP.

 I had to show the people in my office, and we all got a chuckle from teh
 XKCD comic in the PHP documentation for GOTO
 http://ca2.php.net/goto

 Steve


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



And have you seen all the sad faces ...

: {

on http://docs.php.net/manual/en/control-structures.goto.php#92763

Can't be good for them.

-- 
Richard Quadling
Twitter : EE : Zend
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY

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



[PHP-DB] Re: [PHP] Problems w/ goto

2010-12-17 Thread Nicholas Kell

On Dec 17, 2010, at 11:08 AM, Steve Staples wrote:

[snip /]

 
 
 GOTO should never be used like this.
 
 GOTO should never be used.
 
 
 Wow... that brought me back to 1990... using basic and batch files...
 I honestly didn't even know that the GOTO was still in existence,
 especially within PHP.
 
 I had to show the people in my office, and we all got a chuckle from teh
 XKCD comic in the PHP documentation for GOTO
 http://ca2.php.net/goto
 
 Steve

I didn't know it existed in PHP either. The cartoon is priceless. I should 
probably hang that up in my office somewhere.

[PHP-DB] Re: [PHP] Problems w/ goto

2010-12-17 Thread Robert Cummings

On 10-12-17 12:08 PM, Steve Staples wrote:

On Fri, 2010-12-17 at 10:50 -0600, Jay Blanchard wrote:

[snip]
Thank you with your excellent help in the past.  Here is another
puzzler

I am trying to write a program that can have two(2) independent forms
in one PHP file.  When I run the code below [from PHP - A Beginner's
Guide], to which I have added a second form, it freezes.  Without the
goto statements, it runs.  When it does run, it displays both forms
on one Web screen. What I desire is for the first form to be
displayed, the data entered and then the second form displayed.  In
an actual, not test program like this one, the data in the second
form would be dependent on the first form.

What did I do wrong?
[/snip]

You used GOTO.

In this case I would recommend using something like jQuery to 'hide' one
form until the other form is complete. PHP has sent the output to the
browser already, both forms are there and display when you remove the
GOTO.

GOTO should never be used like this.

GOTO should never be used.



Wow... that brought me back to 1990... using basic and batch files...
I honestly didn't even know that the GOTO was still in existence,
especially within PHP.

I had to show the people in my office, and we all got a chuckle from teh
XKCD comic in the PHP documentation for GOTO
http://ca2.php.net/goto

Steve


I was one of the people that argued in favour of GOTO on the Internals 
list a few years ago. GOTO has a use, and a very good one at that. It is 
by far the most efficient construct when creating parsers or other 
similar types of logic flow. The demonized GOTO of the 80s was primarily 
due to jumping to arbitrary points in the code, or in the case of basic 
to arbitrary line numbers in the code which had little meaning for 
future readers. When used properly within a well defined scope and with 
well named labels, GOTO can be a superior choice. If you think GOTO 
doesn't exist in many types of software, you need only grep for it in 
the C source code for PHP, MySQL, and Apache.


Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

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



[PHP-DB] Re: [PHP] Problems w/ goto

2010-12-17 Thread Daniel Brown
On Fri, Dec 17, 2010 at 11:38, Ethan Rosenberg eth...@earthlink.net wrote:

 I am trying to write a program that can have two(2) independent forms in one
 PHP file.  When I run the code below [from PHP - A Beginner's Guide], to
 which I have added a second form, it freezes.
[snip!]
 What did I do wrong?

You presumed that A Beginner's Guide meant that it was a book
for beginners not one written by a beginner.  Firstly, while GOTO
has a place in programming for certain things, the example (and I can
see the difference between the original and your additions) is
atrocious, and is not at all representative of any code you would
ever, ever want to put into production.  That looks like a nightmare
of taking a math final, not knowing the answer, and suddenly realizing
you're in your underwear --- and have explosive uncontrollable
diarrhea on top of it, and your ankles are chained to the chair.  Who
is the author?  I saw one on Amazon by Vikram Vaswani, but there was
no use of GOTO that I could find there.  I'd like to see what other
tips are included, or perhaps to see if that code was used in a
different context (as in, what will work, but what not to do anyway,
or, I wrote this on April Fool's Day).

-- 
/Daniel P. Brown
Network Infrastructure Manager
Documentation, Webmaster Teams
http://www.php.net/

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



[PHP-DB] Re: [PHP] Problems w/ goto

2010-12-17 Thread Steve Staples
On Fri, 2010-12-17 at 12:22 -0500, Robert Cummings wrote:
 On 10-12-17 12:08 PM, Steve Staples wrote:
  On Fri, 2010-12-17 at 10:50 -0600, Jay Blanchard wrote:
  [snip]
  Thank you with your excellent help in the past.  Here is another
  puzzler
 
  I am trying to write a program that can have two(2) independent forms
  in one PHP file.  When I run the code below [from PHP - A Beginner's
  Guide], to which I have added a second form, it freezes.  Without the
  goto statements, it runs.  When it does run, it displays both forms
  on one Web screen. What I desire is for the first form to be
  displayed, the data entered and then the second form displayed.  In
  an actual, not test program like this one, the data in the second
  form would be dependent on the first form.
 
  What did I do wrong?
  [/snip]
 
  You used GOTO.
 
  In this case I would recommend using something like jQuery to 'hide' one
  form until the other form is complete. PHP has sent the output to the
  browser already, both forms are there and display when you remove the
  GOTO.
 
  GOTO should never be used like this.
 
  GOTO should never be used.
 
 
  Wow... that brought me back to 1990... using basic and batch files...
  I honestly didn't even know that the GOTO was still in existence,
  especially within PHP.
 
  I had to show the people in my office, and we all got a chuckle from teh
  XKCD comic in the PHP documentation for GOTO
  http://ca2.php.net/goto
 
  Steve
 
 I was one of the people that argued in favour of GOTO on the Internals 
 list a few years ago. GOTO has a use, and a very good one at that. It is 
 by far the most efficient construct when creating parsers or other 
 similar types of logic flow. The demonized GOTO of the 80s was primarily 
 due to jumping to arbitrary points in the code, or in the case of basic 
 to arbitrary line numbers in the code which had little meaning for 
 future readers. When used properly within a well defined scope and with 
 well named labels, GOTO can be a superior choice. If you think GOTO 
 doesn't exist in many types of software, you need only grep for it in 
 the C source code for PHP, MySQL, and Apache.
 
 Cheers,
 Rob.

Oh, i can see where it would be useful, i just hadn't realized it was
still in existence...   and the cartoon, was blown up, and put in my
cubical :)

RAWR!!


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



Re: [PHP-DB] Re: [PHP] Problems w/ goto

2010-12-17 Thread Daniel Brown
On Fri, Dec 17, 2010 at 12:16, Richard Quadling rquadl...@gmail.com wrote:

 And have you seen all the sad faces ...

 : {

 on http://docs.php.net/manual/en/control-structures.goto.php#92763

 Can't be good for them.

If only people knew how many hours - literally, hours - it took me
to keep that page clean and free from vandalism after GOTO was
introduced.

-- 
/Daniel P. Brown
Network Infrastructure Manager
Documentation, Webmaster Teams
http://www.php.net/

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



[PHP-DB] Re: [PHP] Problems w/ goto

2010-12-17 Thread Daniel P. Brown
On Fri, Dec 17, 2010 at 12:22, Robert Cummings rob...@interjinn.com wrote:

 I was one of the people that argued in favour of GOTO on the Internals list
 a few years ago. GOTO has a use, and a very good one at that. It is by far
 the most efficient construct when creating parsers or other similar types of
 logic flow. The demonized GOTO of the 80s was primarily due to jumping to
 arbitrary points in the code, or in the case of basic to arbitrary line
 numbers in the code which had little meaning for future readers.

Not to mention failure to properly break, as in the OP's code example.

-- 
/Daniel P. Brown
Dedicated Servers, Cloud and Cloud Hybrid Solutions, VPS, Hosting
(866-) 725-4321
http://www.parasane.net/

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