Problems with WHILE
| From: | Frank M. Kromann | Date: | Wed, 19 Apr 2000 19:59:19 +0000 |
| Subject: | Problems with WHILE | ||
| Groups: | php.version4 | ||
| Request: | Send a blank email to php-version4+get-13764@lists.php.net to get a copy of this message | ||
Hi,
I have been looking for an error in the MS SQL Module for some time now and it now seams like the
error is not in this module but in the while loop !
I use the folowing script :
dl("php_mssql70.dll");
print("Before<br>");
$conn = mssql_connect("Online20", "web", "webuser");
if ($conn) {
print("$conn<br>\n");
mssql_select_db("Online20", $conn);
for ($i=0; $i<3; $i++) {
$RS = mssql_query("select * from cNodeType", $conn);
if ($RS) {
print("$RS\n");
$data = array();
do {
if ($tempdata = mssql_fetch_row($RS))
$data[] = $tempdata;
} while (is_array($tempdata));
/*
while (($tempdata = mssql_fetch_row($RS)))
$data[] = $tempdata;
*/
mssql_free_result($RS);
print("<table border=0>\n");
while (list($iRow, $arrRowData) = each($data)) {
print("<tr>\n");
while (list($iCol, $strCol) = each($arrRowData))
print("<td>$strCol</td>");
print("</tr>\n");
}
print("</table>\n");
}
}
mssql_close($conn);
}
print("After<br>");
If I use the do {} while() loop everything works fine but if I use the other loop the script will
work fine for the first two runs but it crashes the $RS variable after two calls to mssql_fetch_row.
I have testet the variable just before exiting the function and it is not the function that causes
the error.
Am i doing anything wrong ?
- Frank
Swwwing A/S
Frank M. Kromann
VP Development
Phone: +45 70 20 77 20
Fax: +45 70 20 77 21
http://www.swwwing.com