A simple implementation method of PHP extended remote connection MSSQL based on MSSQL _php tips

Source: Internet
Author: User
Tags mssql

This article describes the PHP based on MSSQL extended remote connection MSSQL the simple implementation method. Share to everyone for your reference, specific as follows:

Here is a simple example, no security considerations, to deal with it:

<?php
//Connection database
$conn = mssql_connect (' hostip:1433 ', ' user ', ' pass ') or Die ("SQL SERVER database connection failed!") ");
Select Database
mssql_select_db (' UserInfo ', $conn);
SQL statement
$sql = "SELECT Top 5 * from info";
$result = Mssql_query ($sql);
Print output
//print_r ($result);
$num = Mssql_num_rows ($result);
Echo ' has '. $num. " Records <br> ";
if ($num) {
 //loop out each record for
 ($i =0; $i < $num; $i + +) {
 $Row = Mssql_fetch_array ($result);
 echo $Row [0]. $Row [1]. " ...<br/> ";
 }
} else{
 echo "temporarily no data";
}
Close connection
mssql_close ($conn);
? >

More interested in PHP related content readers can view the site: "Php+mssql Database Programming Skills Summary", "PHP based on PDO Operation Database Skills Summary", "PHP+MONGODB Database Operation Skills Encyclopedia", "PHP object-oriented Programming Program", " Summary of PHP string usage, Introduction to PHP+MYSQL database operations, and a summary of PHP common database operations Tips

I hope this article will help you with the PHP program design.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.