Home > Backend Development > PHP Tutorial > PHP uses ODBC to connect to the database, phpodbc connects to the database_PHP tutorial

PHP uses ODBC to connect to the database, phpodbc connects to the database_PHP tutorial

WBOY
Release: 2016-07-13 09:46:19
Original
993 people have browsed it

PHP uses ODBC to connect to the database, phpodbc connects to the database

This article describes the example of PHP using ODBC to connect to the database. Share it with everyone for your reference. The specific implementation method is as follows:

<!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>
 <&#63;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>";
 &#63;>
 </body>
</html>

Copy after login

I hope this article will be helpful to everyone’s PHP programming design.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1034538.htmlTechArticleHow PHP uses ODBC to connect to the database, phpodbc connects to the database This article describes how PHP uses ODBC to connect to the database. Share it with everyone for your reference. The specific implementation method is as follows:...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template