• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 507
  • 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 DMSenior Software EngineerCommented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

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