Use PHP and MySQL to connect to ODBC data

Source: Internet
Author: User
Tags dsn connect odbc mysql php and php and mysql
ODBC refers to the Open data connection, which is the Microsoft-led data driver, it can be connected to other data, through the SQL language to operate the data, of course, PHP also provides a function of the ODBC data connection,
Using PHP to connect with ODBC is done mainly through several functions,
First come to the understanding of several functions with the ODBC interface:
int Odbc_connect (string dsn, string user, string password, int [cursor_type]); Is connected to an ODBC database
DSN, User,password is corresponding to the contents of ODBC, Cursor_type is the choice of cursor type, (can be looked at other documents, where I use the default value)
int Odbc_do (int connection_id, string query), is the function that executes the SQL language, connecton_id is odbc_connecti return value, query is our most concerned SQL language statement,
String Odbc_result (int result_id, mixed field); Is the function of the data taken, result_id is the ODBC_DO to perform the return value, field is the value of the fields index
void odbc_close (int connection_id), which closes the data connection.
We first use these functions to connect with ODBC.
We assume that the DSN in ODBC is set to Yuange user and password can not, of course, if you want to connect with SQL Server need user and password!
There's a watch in Yuange, counter.
<!--odbc.php-->
? Php
$conid =odbc_connect ("Yuange", "" "," ");
$sql = "SELECT * from Counter";
$resid =odbc_do ($conid, $sql);
while (Odbc_fetch_row ($resid)) {
$serial =odbc_result ($resid, 1);
$riqi =odbc_result ($resid, 2);
if ($serial%2) {
echo $serial. "". $riqi. " <br> ";
}
}
Odbc_close ($conid);
?>
What I put on Win98 is PWS plus php4.0 and the mysql3.02 version works well.

"This article copyright belongs to the author and the Osso net jointly owns, if needs to reprint, please indicate the author and the origin"



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.