手机
当前位置:查字典教程网 >编程开发 >php教程 >PHP使用ODBC连接数据库的方法
PHP使用ODBC连接数据库的方法
摘要:本文实例讲述了PHP使用ODBC连接数据库的方法。分享给大家供大家参考。具体实现方法如下:PHPandODBC:XHTMLExample1希...

本文实例讲述了PHP使用ODBC连接数据库的方法。分享给大家供大家参考。具体实现方法如下:

<!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程序设计有所帮助。

【PHP使用ODBC连接数据库的方法】相关文章:

php调整服务器时间的方法

PHP获取数组的键与值方法小结

PHP4 与 MySQL 数据库操作函数详解

PHP+shell实现多线程的方法

PHP生成指定随机字符串的简单实现方法

PHP遍历数组的方法汇总

实现树状结构的两种方法

php使用数组填充下拉列表框的方法

PHP文本数据库的搜索方法

PHP调用三种数据库的方法(3)

精品推荐
分类导航