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.