Hi i just want to know that how to connect php with sql server..because i have database in my sql server....
regards..
Farhad

Recommended Answers

All 6 Replies

<?php
$user='cwarn23';
$password='password';
$database_name='cwarn_phpbb';
mysql_connect('localhost',$user,$password);
mysql_select_db($database_name);
<?php
$user='cwarn23';
$password='password';
$database_name='cwarn_phpbb';
mysql_connect('localhost',$user,$password);
mysql_select_db($database_name);

My dear i want to connect with Sql server not with Mysql...

My dear i want to connect with Sql server not with Mysql...

In that case replace localhost with the ip of the sql server's ip address and on the sql server admin panel allow remote sql then you should be able to perform remote sql tasks. If you need a hand enabling remote sql on your sql server then please describe what control panel you use, what php version your using and mysql version.

Hi Farhad,

Try with mssql_connect functions.

OR

If your server doen't have mssql installed then try with odbc connection...

Steps to use odbc
Goto control panel -> Administrative tools -> Data Sources (ODBC)-> click system DSN -> Create DSN for SQL Server

You can connect SQL server using the below functions ...
$conn = odbc_connect('System dsn name created using ODBC','usernmae', 'password');
$res = odbc_exec($conn,"SELECT * from ajaxmint");

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.