Connecting to a MS SQL Server database with PHP

Today, We want to share with you php ms sql example.In this post we will show you php sql server connection example, hear for php mssql_connect we will give you demo and example for implement.In this post, we will learn about PHP Connect Azure SQL Server Databases with an example.

Connecting to a MS SQL Server database with PHP

Step 1:
Connecting to a MS SQL Server database with PHP

<?php
$host ="***.***.***.***"; 
$username ="admin_v123";
$password ="[email protected]";
$database ="application_v5";

mssql_connect($host, $username, $password);
mssql_select_db($database);
?>

Running MS SQL Queries from PHP

step 2:

<?php
$query ="SELECT col1,col2 FROM products";
$output =mssql_query($query);
while ( $record = mssql_fetch_array($output) )
{
	echo $record["col1"] .", ". $record["col2"] ."<br />";
}
?>

step 3:
And here are two simple example scripts that demonstrate UPDATE and INSERT queries

<?php
$query ="UPDATE products SET
	col1 = 15,
	col2 = 'Welcome, Pakainfo!'"
$output =mssql_query($query);
?>
<?php
$query ="INSERT INTO products
	(col1,col2)
	VALUES(16,'Welcome, Tamilrokers!')";
$output =mssql_query($query);
?>

I hope you get an idea about microsoft drivers for php for sql server.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.