PHP使用ODBC連接數(shù)據(jù)庫的方法
更新時(shí)間:2015年07月18日 11:45:10 作者:鑒客
這篇文章主要介紹了PHP使用ODBC連接數(shù)據(jù)庫的方法,涉及php使用ODBC操作數(shù)據(jù)庫的基本技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下
本文實(shí)例講述了PHP使用ODBC連接數(shù)據(jù)庫的方法。分享給大家供大家參考。具體實(shí)現(xiàn)方法如下:
<!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程序設(shè)計(jì)有所幫助。
您可能感興趣的文章:
- 關(guān)于php連接mssql:pdo odbc sql server
- PHP5中使用PDO連接數(shù)據(jù)庫的方法
- PHP中PDO連接數(shù)據(jù)庫中各種DNS設(shè)置方法小結(jié)
- ThinkPHP框架基于PDO方式連接數(shù)據(jù)庫操作示例
- PHP實(shí)現(xiàn)的pdo連接數(shù)據(jù)庫并插入數(shù)據(jù)功能簡單示例
- tp5(thinkPHP5)框架連接數(shù)據(jù)庫的方法示例
- PHP7使用ODBC連接SQL Server2008 R2數(shù)據(jù)庫示例【基于thinkPHP5.1框架】
- tp5(thinkPHP5)操作mongoDB數(shù)據(jù)庫的方法
- thinkPHP5實(shí)現(xiàn)數(shù)據(jù)庫添加內(nèi)容的方法
- tp5(thinkPHP5)框架數(shù)據(jù)庫Db增刪改查常見操作總結(jié)
- PHP利用pdo_odbc實(shí)現(xiàn)連接數(shù)據(jù)庫示例【基于ThinkPHP5.1搭建的項(xiàng)目】
相關(guān)文章
關(guān)于zend studio 出現(xiàn)亂碼問題的總結(jié)
本篇文章是對zend studio出現(xiàn)亂碼問題進(jìn)行了詳細(xì)的總結(jié)介紹,需要的朋友參考下2013-06-06
php array_filter除去數(shù)組中的空字符元素
php array_filter除去數(shù)組中的空字符元素,array_filter() 函數(shù)根據(jù)回調(diào)函數(shù)過濾數(shù)組中的值,省略回調(diào)函數(shù)則默認(rèn)過濾空值,需要的朋友可以參考下。2011-11-11

