Link to home
Start Free TrialLog in
Avatar of doramail05
doramail05Flag for Malaysia

asked on

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

ASKER CERTIFIED SOLUTION
Avatar of kaminda
kaminda
Flag of Sri Lanka image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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
Avatar of Vimal DM
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