时间:2021-07-01 10:21:17 帮助过:15人阅读
具体实现方法如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>PHP and ODBC: XHTML Example 1</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> </head> <body> <?php $conn = odbc_connect( "DRIVER={MySQL ODBC 3.51 Driver};Server=localhost;Database=phpodbcdb", "username", "password"); if (!($conn)) { echo "<p>Connection to DB via ODBC failed: "; echo odbc_errormsg ($conn ); echo "</p>\n"; } $sql = "SELECT 1 as test"; $rs = odbc_exec($conn,$sql); echo "<table><tr>"; echo "<th>Test</th></tr>"; while (odbc_fetch_row($rs)) { $result = odbc_result($rs,"test"); echo "<tr><td>$result</td></tr>"; } odbc_close($conn); echo "</table>"; ?> </body> </html>
相关推荐:
php SQLserver 导入 Mysql
php 数据库类 适用于 mysql sql service
超轻的 PHP 数据库工具包
以上就是PHP使用ODBC连接数据库的实例的详细内容,更多请关注Gxl网其它相关文章!