www.pickatutorial.com Computer Tutorials
Top eBooks: C/C++ | C# | Android | Mathematics | Database | Cloud | Graphics | Networking | Oracle | Hardware | AI
Top Tutorials: C/C++ | C#.NET | PHP MySQL | Java | Java Script | jQuery | HTML | xHTML | HTML5 | VB Script| CSS
Lessons PHP with ODBC 1 Bookmark and Share
Lesson 1
Lesson 2
Lesson 3
Lesson 4
Lesson 5
Lesson 6
Lesson 7
Lesson 8
Lesson 9
Lesson 10
Lesson 11
Lesson 12
Lesson 13
Lesson 14
Lesson 15
Lesson 16
Lesson 17
Lesson 18
Lesson 19
Lesson 20
Lesson 21
Lesson 22
Lesson 23
Lesson 24
Lesson 25
Lesson 26
Lesson 27
Lesson 28
Lesson 29
Lesson 30
Lesson 31
Lesson 32
Lesson 33
Lesson 34
Lesson 35
Lesson 36
Lesson 37
Lesson 38
Lesson 39
Lesson 40
Lesson 41
Lesson 42
Lesson 43
Lesson 44
ODBC is an Application Programming Interface (API) that allows us to connect to a data source, for example MS Access database. In large projects it is not a recommended practice to access databases through ODBC, however.

How to Create an ODBC Connection?
With the help of an ODBC connection, we can connect to any database, on any computer in our network, as long as an ODBC connection is available.

Just follow the below mentioned steps to create an ODBC connection to a MS Access Database:
  1. Open the Administrative Tools from your Control Panel.
  2. Double-click on the Data Sources (ODBC) icon inside.
  3. Choose the System DSN tab.
  4. Click on Add in the System DSN tab.
  5. Select the Microsoft Access Driver. Click Finish.
  6. In the next screen, click Select to locate the database.
  7. Give the database a Data Source Name (DSN).
  8. Click OK.
It is important to note here that this configuration has to be done on the computer where the web site is located. If you are running IIS on your own computer, the instructions above will work fine, but if your web site is located on a remote server, you have to have physical access to that server. You can also ask your web hosting service provider to to set up a DSN for you.

Connecting to an ODBC Data Source
The odbc_connect() function is used to connect to an ODBC data source. This function takes four parameters:
the data source name,
username, password,
and an optional cursor type.

The odbc_exec() function is used to execute an SQL statement.

PHP ODBC Example
The following code example creates a connection to a DSN called northwind, with no username and no password and then it creates an SQL and executes it:

$sql="SELECT * FROM customers";

Home - Advertise - Contact - Disclaimer - About Us
© Since 2006 pickatutorial.com -- All Rights Reserved.