Sunday, July 1, 2012

Connecting to ODBC using PHP

7/01/2012



<?php
/* 
Online PHP Examples with Source Code
website: http://4evertutorials.blogspot.in/
*/


// connect to a DSN "database" with a user and password "4evertutorials"
$connect = odbc_connect("database", "4evertutorials", "4evertutorials");


// query the users table for name and surname
$query = "SELECT name, surname FROM users";



// perform the query
$result = odbc_exec($connect, $query);



// fetch the data from the database

while(odbc_fetch_row($result))
{
  $name = odbc_result($result, 1);
  $surname = odbc_result($result, 2);
  print("$name $surname\n");

}


// close the connection
odbc_close($connect);

?>

helpful? Share this

The Editorial Team of 4everTutorials consists of a group of PHP Professionals.

0 comments:

 

© 2014 4everTutorials. All rights resevered.

Back To Top