Home php教程 PHP开发 Simple implementation method of PHP extending remote connection to MSSQL based on mssql

Simple implementation method of PHP extending remote connection to MSSQL based on mssql

Dec 20, 2016 pm 04:39 PM
mssql

The example in this article describes the simple implementation method of PHP extending remote connection to MSSQL based on mssql. Share it with everyone for your reference, the details are as follows:

What is given here is a simple example, no security considerations are taken, handle it by yourself:

<?php
// 连接数据库
$conn = mssql_connect(&#39;hostip:1433&#39;,&#39;user&#39;,&#39;pass&#39;) or die("SQL SERVER 数据库连接失败!");
// 选择数据库
mssql_select_db(&#39;UserInfo&#39;, $conn);
// sql语句
$sql = "SELECT TOP 5 * FROM info";
$result = mssql_query($sql);
//打印输出
//print_r($result);
$num = mssql_num_rows($result);
echo &#39;有&#39;.$num."条记录<br>";
if($num){
 //循环出每一条记录
 for( $i=0;$i<$num;$i++ ){
 $Row = mssql_fetch_array($result);
 echo $Row[0].$Row[1]."...<br/>";
 }
}else{
 echo "暂无数据" ;
}
//关闭连接
mssql_close($conn);
?>
Copy after login

I hope this article will be helpful to everyone in PHP programming.

For more related articles on the simple implementation method of PHP extending remote connection to MSSQL based on mssql, please pay attention to the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)