Justtechjobs.com Find a programming school near you






Online Campus Both


php-db | 2000121

Re: [PHP-DB] dead loop From: Toby Butzon (php-lists <email protected>)
Date: 12/03/00

Try limiting the condition of the suspect for-loop and see what you get. For instance, instead of:

for($i=1;$i<=$max;$i++) ...etc...

use this:

for($i = 1; $i <= 100 && $i <= $max; $i++) ...etc...

The error could be somewhere else... if it's in this loop, the script will stop in time with this added condition so it won't use up all your memory and we'll know to concentrate on this. Let me know what happens :)
Toby Butzon
[ criticism spurs improvement ]

  ----- Original Message -----
  From: catteddy
  To: php-db <email protected>
  Sent: Saturday, December 02, 2000 5:42 PM
  Subject: [PHP-DB] dead loop

  Hello, I'm Teddy. I write a program file like belo using PHP
  <?php

  require 'functions.php';

  $link = mssql_connect($DB_SERVER,$DB_LOGIN,$DB_PASSWORD);

  if(!$link) {

  DisplayErr("Can not connect to the DB");

  exit();

  }

  $SEC_DB = mssql_select_db($DB,$link);

  if(!$SEC_DB) {

  DisplayErr("Can not select the DB");

  exit();

  }

  $result = mssql_query("SELECT Q_ID FROM Quiz_Content WHERE Subject_ID = 2",$link);

  if(!$result) {

  DisplayErr("Can not execute the statement");

  exit();

  }

  $max = mssql_num_rows($result);

  echo $max;

  $ran_s[] = 0;

  while($row = mssql_fetch_array($result)) {

  $ran_s[] = $row["Q_ID"];

  }

  reset($ran_S);

  for($i=1;$i<=$max;$i++) {

  echo $ran_s[$i];

  echo "<BR>";

  }

  ?>

  I was using WindowNT4.0 as the web server and Microsoft SQL2000. They both install in the same machine(PII 400 with 128MB RAM).

  Every time I execute the program. It just use up almost all the resource in the NT. When I see the TaskManager. PHP is using 99% resource.

  I had ever try another methord to output the result. The problem may occur in the last For loop. It just display some number very big. I had attach the script of the table.

  Please help me!

      Thanks a lot

                                                                                                                                                          Teddy

------------------------------------------------------------------------------

  --
  PHP Database Mailing List (http://www.php.net/)
  To unsubscribe, e-mail: php-db-unsubscribe <email protected>
  For additional commands, e-mail: php-db-help <email protected>
  To contact the list administrators, e-mail: php-list-admin <email protected>