Re: Unexplained Timeout

From: Date: Tue, 17 Jul 2001 02:14:30 +0000
Subject: Re: Unexplained Timeout
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-58157@lists.php.net to get a copy of this message
Jeff Oien pressed the little lettered thingies in this order... > I get a 30 timeout on the line indicated when executing this code > and can't figure it out. Does anyone know why? Thanks. > Jeff Oien > You should pay attention to which variables are in quotes and which are not. PHP (and every other mature programming language) can behave unpredictably (well, it's predictable if you know what it's doing, it probably just isn't how you want it to act) if you get these mixed up. My guess is that PHP is having a hard time guessing the variable types for comparison. PHP does a pretty good job of magically guessing the type, but if you're not careful, you may leave an ambiguous variable type and it will guess wrong. Generally speaking, strings should be in quotes and numbers (integers, floats, etc) should not. See: http://www.php.net/manual/en/language.types.php And follow below... > > if ($missing == "1") { > At this point, you have literally told PHP to see if $missing is a string with a value of one. This is different than an integer with a value of 1. My guess is that PHP probably correctly guessed what you were trying to say here despite the fact that it isn't correct (it is correct enough to not be ambiguous, but that doesn't make it correct). > echo " > <html> > <head> > <title>Error</title> > </head> > <body bgcolor=\"#FFFFFF\" text=\"#000000\" link=\"#0000ff\" > vlink=\"#660099\"> <h3>Error</h3> > > Required information was missing: > <ul>"; > > $z = "1"; > You have just set $z to a string with the value of 1. Obviously not what you wanted. If you remove the quotes, $z will be set to the integer 1. > while ($z <= "$Number_Children") { You have just told PHP to compare a string with the value of 1 (what you previously defined as $z) with another string defined by $Number_Children. Had you either used $z = 1 (no quotes) or $z <= $Number_Children (no quotes), PHP probably would have correctly guessed the type of these variables. The way that you made it, the types are ambiguous and you shouldn't ever expect PHP to guess correctly. > >>error> if (${"element2$z"} == "select") { > echo "<li>Please make a selection for Child $z</li>"; > } > if ((${"year$z"}).(${"month$z"}).(${"day$z"}) >= 20000401 > && > (${"year$z"}).(${"month$z"}).(${"day$z"}) >= 19980902) { > if (${"coopmonth$z"} == "select") { > echo "<li>Please select coop month to serve for Child $z</li>"; > } > $z++; > } > } > echo " > </ul> > Please use your <a href=\"javascript:history.go(-1);\">Back button</a> > and > try again > (please do <b>not</b> Reload or Refresh your browser) > </body> > </html> > "; > exit; > } > I didn't really examine the rest of the code too closely, but I'd be willing to bet that the code will start working once the types are correct (remove the quotes from around variables for which you expect integers). If not, then at least you can rest assured that PHP is using the proper variable types. Good luck... Christopher Ostmo a.k.a. tech@AppIdeas.com AppIdeas.com Innovative Application Ideas Meeting cutting edge dynamic web site needs since the dawn of Internet time (1995) For a good time, http://www.AppIdeas.com/

« previous php.general (#58157) next »