Add to Google

While Loop - how to stop the timeout

free web hosting
Open Discussion > CONTRIBUTE > Computers > Programming Languages > PHP Programming

While Loop - how to stop the timeout

moldboy
I have written a piece of code that is to make a forum which contains a table consiting of two colums and a determind number of rows with a while loop, however when I test the page it goes and goes, and then returns an error stating that the maximum 30 second limit has been reached, I understand what that means I just don't know why it's looping forever:
CODE

while ($weightnum > 0);
{
echo "<tr>";
   echo   '<td><input name="wname"' . $appendval . ' type="text" id="wname" value="Catagorie Name"></td>';
   echo   '<td><input name="wper"' . $appendval . ' type="text" id="wper" value="Percent Value"></td>';
   echo "</tr>";
$appendval = $apendval + 1;
$weightnum = $weightnum - 1;
}


Also Am I appending a number to my variable correctly?

 

 

 


Reply

Tyssen
Have you specified an initial value for $weightnum anywhere? Cos if you haven't, your counter doesn't know what it's s'posed to be counting down from. I would've thought it'd be easier to count up, but I don't s'pose it really matters.

Reply

moldboy
Yeah it pulls it from a forum page, I guess I could check to make sure I spelled it right. I also have a habbit of using the $ in my form variables, could check.

Also on the last two lines, could I not say:
CODE

$appendval = ++;
$weightnum = --;

??

Notice from BuffaloHELP:
Edited as per request.

Reply

vujsa
QUOTE(moldboy @ Jun 14 2005, 12:17 AM)
Also on the last two lines, could I not say:
CODE

$appendval = ++;
$weightnum = --;

*



Should be done like this:
CODE

$appendval++;
$weightnum--;


That will increment or decrement the variable.

Also, I wrote a tutorial about this type of PHP scripting. It's on AstaHost, the sister site to Trap17.

Here is the tutorial link:
Rapid HTML code generation using simple PHP

It might interest you. cool.gif

vujsa

 

 

 


Reply

moldboy
Okay, I kinda have to vent here for just one moment, STUPID PHP AND IT'S STUPID LITTLE ISSUES.

So I found out what the problem was. Turns out that
CODE
while ($weightnum > 0);
{
echo "<tr>";
  echo   '<td><input name="wname"' . $appendval . ' type="text" id="wname" value="Catagorie Name"></td>';
  echo   '<td><input name="wper"' . $appendval . ' type="text" id="wper" value="Percent Value"></td>';
  echo "</tr>";
$appendval = $apendval + 1;
$weightnum = $weightnum - 1;
}

won't work however:
CODE
while ( $weightnum > 0 ){
echo "<tr>";
  echo   '<td><input name="wname"' . $appendval . ' type="text" id="wname" value="Catagorie Name"></td>';
  echo   '<td><input name="wper"' . $appendval . ' type="text" id="wper" value="Percent Value"></td>';
  echo "</tr>";
$appendval = $apendval + 1;
$weightnum = $weightnum - 1;
}


That does... can you spot the diffrence? Look at the {.

Oh but thanks for the tutorial link, I just might have to use it. One rep point.

Reply

Tyssen
Yeah, I've had the same problem. I've only recently been playing around with PHP - before that it was all ASP - and I'm always getting caught out by missing ; and { which are a lot harder to spot than a missing then or end if.

Reply

moldboy
Yeah the only other coding I've even kinda done is HTML, and I'll tell you, PHP may be easy but HTML certinaly is easier! It's just not so picky. dry.gif

Reply

karlo
QUOTE(moldboy @ Jun 14 2005, 12:40 PM)
I have written a piece of code that is to make a forum which contains a table consiting of two colums and a determind number of rows with a while loop, however when I test the page it goes and goes, and then returns an error stating that the maximum 30 second limit has been reached, I understand what that means I just don't know why it's looping forever:
CODE

while ($weightnum > 0);
{
echo "<tr>";
   echo   '<td><input name="wname"' . $appendval . ' type="text" id="wname" value="Catagorie Name"></td>';
   echo   '<td><input name="wper"' . $appendval . ' type="text" id="wper" value="Percent Value"></td>';
   echo "</tr>";
$appendval = $apendval + 1;
$weightnum = $weightnum - 1;
}


Also Am I appending a number to my variable correctly?
*


I suggest using for() loops instead of while. In for(), it's easy... example is below:

CODE
for($i=0;$i<5;$i++){
echo("testing $i<br>");
}

Reply

beeseven
The reason HTML is easier is because it's not a real language. HTML is markup: that means it tells stuff what to look like. It's not considered a language because there are no variables or conditionals or stuff like that.

Reply

moldboy
QUOTE(beeseven @ Jun 18 2005, 11:11 AM)
The reason HTML is easier is because it's not a real language. HTML is markup: that means it tells stuff what to look like. It's not considered a language because there are no variables or conditionals or stuff like that.
*



Yeah I know, that's why I wanted to learn an actual rograming language. Hence PHP

Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

Recent Queries:-
  1. while loops in conversation - 438.49 hr back. (1)
  2. how to hide a loop using smarty - 508.06 hr back. (1)
  3. while loop time out - 809.53 hr back. (2)
  4. timeout for while loop - 857.87 hr back. (1)
  5. php while loop submit button loop forever - 999.60 hr back. (1)
  6. php while loop timeout - 1294.57 hr back. (1)
  7. how to timeout in while loop - 1560.64 hr back. (1)
  8. while loop with timeout - 1252.29 hr back. (2)
  9. timeout while loop - 2019.74 hr back. (1)
  10. scandir timeout - 2104.95 hr back. (1)
Similar Topics

Keywords : Loop Timeout

  1. Loop Through Form - How do you do it? (8)
    In ASP you'd do this: CODE For Each Field in Request.Form So how do you do it in PHP? I
    want to loop through a form, check to see if it has a value and if so, append to a string to send as
    the body of my email....
  2. Php Date() Problem [resolved] - date() seems to loop same ninute. (4)
  3. Help Needed With Directory/file Listing Code Infinite Loop - Made an infinite loop but why is this so? (5)
    Hi all ive got a small and simple (for the moment atleast /unsure.gif"
    style="vertical-align:middle" emoid=":unsure:" border="0" alt="unsure.gif" /> )file and directory
    listing script in php as follows CODE $dir = "."; $num = 0; $file = scandir($dir); while($file
    = scandir($dir)){     echo $file ;     echo " ";     $num = $num + 1;      }; the concept is
    simple enough, the directory to start with is the current one, so scan this directory and while we
    have a result do a loop to echo the file/directories found, incriment the array number by one so we
    get the...
  4. For Loop - for loop problem (5)
    i'd like to make for loop which dependes on a $_GET variable: here is my tries: CODE if
    (isset($_GET ) { switch($_GET )     {         case 'asc': $exp1 = "$x>0"; $exp2 =
    "$x=$total";             $condition = '$x++';             break;         case
    'desc'; $exp1 = "$x=$total"; $exp2 = "$x>0";             $condition = '$x--';
                break;     } } then CODE for($exp1; $exp2; $condition) { //** do something
    **// } that is what i want to do, sure this code is wrong so what is the valid code?!!...
  5. For Each Loop Help - (1)
    I have a page where I list a number of records from my db. Under each record I have a checkbox and a
    text field. At the bottom of the list I have a submit button. I want to be able to check various
    boxes and edit the text field then click the button to update all of the records. I currenlty have
    the following and it updates the records ok (checkbox, I haven't messed with the text field yet)
    when I first check the boxes but it will not update the db when I uncheck the boxes. My form: PHP
    Code: CODE if(isset($_POST )); $active1=serialize($_POST );...






Looking for loop, stop, timeout






*SIMILAR VIDEOS*
Searching Video's for loop, stop, timeout

*MORE FROM TRAP17.COM*
advertisement



While Loop - how to stop the timeout