PHP使用ODBC連接數(shù)據(jù)庫的方法
更新時間:2015年07月18日 11:45:10 作者:鑒客
這篇文章主要介紹了PHP使用ODBC連接數(shù)據(jù)庫的方法,涉及php使用ODBC操作數(shù)據(jù)庫的基本技巧,具有一定參考借鑒價值,需要的朋友可以參考下
本文實(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)文章
php數(shù)組函數(shù)序列之a(chǎn)rray_search()- 按元素值返回鍵名
array_search() 函數(shù)與 in_array() 一樣,在數(shù)組中查找一個鍵值。如果找到了該值,匹配元素的鍵名會被返回。如果沒找到,則返回 false2011-11-11
php 根據(jù)url自動生成縮略圖并處理高并發(fā)問題
服務(wù)器生成縮略圖的時機(jī)一般分為兩種:上傳文件時生成、訪問時生成,下面為大家介紹下php根據(jù)url自動生成縮略圖并處理高并發(fā)問題2014-01-01
PHP中spl_autoload_register()和__autoload()區(qū)別分析
這篇文章主要介紹了spl_autoload_register()和__autoload()區(qū)別,需要的朋友可以參考下2014-05-05

