Heim  >  Artikel  >  Backend-Entwicklung  >  PHP 使用 ODBC 连接 Mysql 数据库_PHP教程

PHP 使用 ODBC 连接 Mysql 数据库_PHP教程

WBOY
WBOYOriginal
2016-07-21 14:53:431262Durchsuche

本文主要给大家介绍如何使用PHP 通过 ODBC 连接 Mysql 数据库,关于其中的原理这里就不再多介绍了,请大家直接测试下边的代码:

Copy to ClipboardLiehuo.Net Codes引用的内容:[www.bkjia.com] br />"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">


PHP and ODBC: XHTML Example 1



$conn = odbc_connect(
"DRIVER={MySQL ODBC 3.51 Driver};Server=localhost;Database=phpodbcdb",
"username", "password");
if (!($conn)) {
echo "

Connection to DB via ODBC failed: ";
echo odbc_errormsg ($conn );
echo "

\n";
}

$sql = "SELECT 1 as test";
$rs = odbc_exec($conn,$sql);
echo "";
echo "";
while (odbc_fetch_row($rs))
{
$result = odbc_result($rs,"test");
echo "";
}
// 辛苦整理教程,勿恶意采集 VeryHuo_COM
odbc_close($conn);
echo "
Test
$result
";
?>

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/364745.htmlTechArticle本文主要给大家介绍如何使用PHP通过 ODBC 连接 Mysql 数据库,关于其中的原理这里就不再多介绍了,请大家直接测试下边的代码: Copy to Cl...
Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn