mssql_fetch_array not working?
| From: | Benjamin Walling | Date: | Mon, 13 May 2002 21:15:39 +0000 |
| Subject: | mssql_fetch_array not working? | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-19159@lists.php.net to get a copy of this message | ||
I apologize if the answer to this is incredibly simple. I'm trying to learn
PHP, and evaluate whether to change our site away from ASP.
I have the following php code, and I can't get any results.
I have add the line echo mssql_num_rows($rs); to see how many rows are
returned, and I get 11 (there are 11 rows in this table).
The page outputs only "11<br>Done". Why am I not getting any thing into
$row? Why do I only get 1 <br> (I would expect 11)?
--Begin Code
$db = mssql_connect("domino","uid","pwd");
if ($db)
{
$dbs = mssql_select_db("acuity_edd_app",$db)
or die("Couldn't set DB");
$sql = "SELECT * FROM timItemClass ORDER BY ItemClassID";
$rs = mssql_query($sql);
echo mssql_num_rows($rs);
if ($rs)
{
while ($row = mssql_fetch_array($rs));
{
echo $row["ItemClassKey"];
echo "<br>";
}
}else{
echo "No results\n";
}
echo "Done\n";
}else{
echo "Unable to connect to database.\n";
}
--End Code