ODBC with MS Access97
| From: | Srinivasan Ramakrishnan | Date: | Tue, 17 Oct 2000 00:25:14 +0000 |
| Subject: | ODBC with MS Access97 | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-20486@lists.php.net to get a copy of this message | ||
Hi,
I'm using Apache 1.3.14 on Win98 with PHP 4.0.2 as my test machine.
I'm trying to connect to an MS Access 97 database using ODBC. When I try to
loop thru the rows I get a function undefined error for the functions
$odbc_num_fields() and $odbc_result().
However when I use $odbc_result_all(), it works perfectly. I have commented
out the error prone code.
What's wrong, is it a problem with the PHP implementation on Win98?
BTW, what is the optional HTML table formatting argument {the 2nd arg}for
$odbc_result_all()?
Here's the code.
<?
$db_conn_id = odbc_connect("MS Access 97 Database","","");
$sql = "SELECT name.* FROM name";
$result_id = odbc_exec($db_conn_id,$sql);
// $num_cols = $odbc_num_fields($result_id);
/*$num_cols = 3; #inserted since I am getting an error in the line above
echo "<table>";
while(odbc_fetch_row($result_id)){
echo "<tr>";
for($i=1;$i <= $num_cols;$i++){
echo ("<td>".$odbc_result($result_id,$i)."</td>");
// getting an error here too
}
echo "</tr>";
}
echo "</table>";*/
$exec_db = odbc_result_all($result_id);
odbc_close($db_conn_id);
?>
Thanks,
Srini
---------------------------------------------------------
First they ignore you;
Then they laugh at you;
Then they fight with you;
and in the end you win.
--Mahatma Gandhi
--------------------------------------------------------