How to connect MSSQL using php

<?php
$connection_string = ‘DRIVER={SQL Server};SERVER=.\sqlexpress;DATABASE=ardunio’;

$user = ”;
$pass = ”;

$connection = odbc_connect( $connection_string, $user, $pass );
if(!$connection)
{
print(“test”);
}
else
{
echo odbc_error();
print(“test”);

}
$result=odbc_exec($connection,”select *from dbo.[voltage2]”);
while($rows=odbc_fetch_object($result)){
$data[]=$rows;
}

print_r($data);

//$connection = odbc_connect(“Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=ardunio;Data Source=.\sqlexpress”, ”, ”);

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s