• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 500
  • Last Modified:

trusted connection to sql server 2008 from php

below is the code for sql authenticaion connection string

how about for trusted connection to sql server
<?php
session_start();
if ($_SERVER['REQUEST_METHOD']=='POST'){	
	$myServer = "localhost";

	$myUser = "sa";
	$myPass = "#$";
	$myDB = "db01";

	//connection to the database
	$dbhandle = mssql_connect($myServer, $myUser, $myPass)
	  or die("Couldn't connect to SQL Server on $myServer");

Open in new window

0
doramail05
Asked:
doramail05
1 Solution
 
kamindaCommented:
Here is the msdn link discribes how you can do this

http://msdn.microsoft.com/en-us/library/cc296205(v=sql.90).aspx

code is something like this

$serverName = "(local)";
$connectionInfo = array( "Database"=>"AdventureWorks");

/* Connect using Windows Authentication. */
$conn = sqlsrv_connect( $serverName, $connectionInfo);
if( $conn === false )
{
     echo "Unable to connect.</br>";
     die( print_r( sqlsrv_errors(), true));
}

0
 
AmmarRCommented:
Dear

if you want to use Windows Authentication with PHP, its good to know some important stuff  about it

http://blogs.msdn.com/b/brian_swan/archive/2010/02/10/sql-server-driver-for-php-understanding-windows-authentication.aspx
0
 
Vimal DMCommented:
Hai,

just search for the below one's online,you will find the easy way of doing this

1) $conn = odbc_connect('myDSN','','');

2) $query = "select * from cars";
  //perform the query
  $result=odbc_exec($conn, $query);

3) $colName = odbc_num_fields($result);


Just look for this link,

http://www.webcheatsheet.com/PHP/connect_mssql_database.php
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now