php-db | 2000121
Date: 12/05/00
- Next message: bryan: "[PHP-DB] Bringing in rows"
- Previous message: Roberto Sartor: "[PHP-DB] Problem ORA-03106: fatal two-task communication prot ocol error with varchar2 column"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hi, I am teddy. I had write a letter two days ago. It's about a dead loop of a php program. When the program execute,
it will use up all the resource in my machine. I use NT4 as the web server.
I use Microsoft SQL2000 as the data base.
I'm now doing a school project using PHP. It is a online Quiz system. I use a Multi-Dimensional array to store the question ID and result from the user.
I want to make a random question to the user. Each time it select 8 questions.
The array will like this:
$question =array(1 => array("Question_ID","Result"))
I use the select to input the question ID:
<?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);
$ran_s[] = 0;
while($row = mssql_fetch_array($result)) {
$ran_s[] = $row["Q_ID"];
**********
}
reset($ran_s);
for($i=0;$i<=5;$i++) {
echo $ran_s[$i];
echo "<BR>";
}
?>
In my data base, the shold have 10 records, when I add echo $row["Q_ID"]; at the position with **********. The record disply correctly at the first ten line. But hang atlast.
The record it display is :
4
6
7
9
12
14
19
23
0
1
23
19
0
5
The correct answer should be:
4
6
7
9
12
14
19
23
The dead loop seems not cause by the for statement. It is very strange that the last two number is 0 and 5, the first is 1. It should not have such record!
Please help me.
Thanks a lot.
- Next message: bryan: "[PHP-DB] Bringing in rows"
- Previous message: Roberto Sartor: "[PHP-DB] Problem ORA-03106: fatal two-task communication prot ocol error with varchar2 column"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

