Showing posts with label Microsoft SQL Server. Show all posts
Showing posts with label Microsoft SQL Server. Show all posts

Monday, 5 September 2011

PHP MS SQL Server database connection

Please follow the steps given below to connect MSSQL with php:

1. Settings related to your php.ini file:

a) search the variable mssql.secure_connection in your php.ini file and put it to on mode if its off
b) remove comment from the dll extention php_mssql.dll (i.e. remove the ; from the front of the extention )

2. Settings related to the dll files.

download a file name ntwdblib.dll from the internet. you can download it from here or can search on internet for that. copy the downloaded dll to the apache/bin directory and for IIS copy it to the php extention directory (if path not known can be found in php.ini for variable extension_dir)

also you need to have your php_mssql.dll in your php extension directory. if its not present please download it and copy it to the default php extension directory can be found here.

3. restart all your services (i.e. php and apache or iis) and you can use the script given below to connect to your SQL Server.

<?php
$mssql_hostname = "(local)";
$mssql_user = "swadesh";
$mssql_password = "behera";
$mssql_database = "db";
$prefix = "";
$bd = mssql_connect($mssql_hostname, $mssql_user, $mssql_password) or die("Could not connect database");
mssql_select_db($mssql_database, $bd) or die("Could not select database");

?>

Enhanced by Zemanta

Error Creating a ODBC datasource for SQL-Server

 
While i was trying to create an connection to my server using ODBC database connection, i came across the following error.

 
Connection failed
SQL State '01000'
SQL Server error 53
[microsoft][ODBC SQL Server Driver][DBNETLIB]Connection Open
Connection failed
SQL State '08001
SQL Error 17
[microsoft][ODBC SQL Server Driver][DBNETLIB]SQL Server does not exist or access denied.

 

Selecting the 'Name Pipes' in the Network libraries did the trick.

-------------------------------------------

Control Panel->Administrative Tools->Data Sources(ODBC ->ODBC Data Source Administrator -> Add->SQL Server
Configure

Name: SQLServer

Server: <servername>

Click Next

Click -> Client Configuration..

Network libraries -> Select Named Pipes

Enhanced by Zemanta

SQL Server 2005 login error

SQL Server 2005: While login Error 18452 (not associated with a trusted sql server connection)

I found the following simple solution
Go to Start > Programs > Microsoft SQL Server 2005 > 
SQL Server Management Studio
Right-click the Server name,
select Properties > Security
Under Server Authentication,
select SQL Server and Windows Authentication Mode
The server must be stopped and re-started before this will take effect..."

It has solved my problem, so I hope it could be helpful for you too.
Enhanced by Zemanta