Connecting php with ms sql server

Suppose you have ms sql server and php installed, also both are configured with each other then here is the connection file that u have to developed in order to interact with the database of ms sql server in php.


$host="localhost"; \\name of the web server



$user="adeel"; \\username of ms sql server will come here



$pass="yourpassword"; \\password of ms sql server will come here with respect to username



$db_name="yourdatabase"; \\name of your database will come here



mssql_connect("$host","$user","$pass") or die("cannot connect to the database server");



mssql_select_db("$db_name") or die("cannot select the database");



save this code and give name to the php file such as conn.php and include in every file where which u want database interaction.

0 comments: