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.

Read Also:  Date Range Search Jquery DatePicker using Ajax PHP with MySQL

About Pakainfo

I am Jaydeep Gondaliya, a software engineer, the founder and the person running Pakainfo. I'm a full-stack developer, entrepreneur and owner of Pakainfo.com. I live in India and I love to write tutorials and tips that can help to other artisan, a Passionate Blogger, who love to share the informative content on PHP, Javascript, JQuery, Laravel, Codeigniter, VueJS, AngularJS and Bootstrap from the early stage.

View all posts by Pakainfo →

Leave a Reply

Your email address will not be published. Required fields are marked *