‘壹’ php + mssql分页查询 求助
http://blog.163.com/shaoyu_lin/blog/static/38024599201278113415330/
‘贰’ PHP如何连接mssql一个实例
你的写法没问题,不过可以试试指定端口((local)abc,1433)
另外,连接不上有错误信息吗?错误信息发出来看看
我试了下,php连接sqlsrv除了安装sqlsrv的扩展外还需要安装 odbc驱动 ,在微软sqlsrv for php 有介绍 ,根据你下载的 sqlsrv扩展版本安装 odbc驱动
‘叁’ 运行php查询mssql数据库,得到空白页,是不是连接不上数据库
不知道你的SQL Server版本是多少?
如果是2000的,你可以用mssql_connect进行连接,否则你只能够用SQLSRV扩展进行连接。
PHP5.2只能雹或够使用SQLSRV 2.0,下面有链接可以源毁伍直接到微软网站上下载:
http://download.microsoft.com/download/C/D/B/CDB0A3BB-600E-42ED-8D5E-E4630C905371/SQLSRV20.EXE
sqlsrv连接方式:
<?php
$serverName = "serverNamesqlexpress"; //serverNameinstanceName
$connectionInfo = array( "Database"=>"dbName", "UID"=>"userName", "PWD"=>"password");
$conn = sqlsrv_connect( $serverName, $connectionInfo);
if( $conn ) {
echo "Connection established.<br />";
}else{
echo "Connection could not be established.<br />";
die( print_r( sqlsrv_errors(), true));
}
?>
更详细信息参见:http://www.php.net/manual/zh/function.sqlsrv-connect.php
mssql_connect连接余租方式:
<?php
// Server in the this format: <computer><instance name> or
// <server>,<port> when using a non default port number
$server = 'KALLESPCSQLEXPRESS'
// Connect to MSSQL
$link = mssql_connect($server, 'sa', 'phpfi');
if (!$link) {
die('Something went wrong while connecting to MSSQL');
}
?>
更详细信息参见:http://cn2.php.net/manual/zh/function.mssql-connect.php
‘肆’ 求php连接MSSQL数据源码份,有注释最好~~
$conn = mssql_connect('127.0.0.1','用户名','密码') or die('连接不成功'); //连接服务器
mssql_select_db('数据名',$conn) or die('数据库不存在'); //选择数据
mssql_query("sql语句");//查询数据
连接需要服务器php_mssql.dll扩展,php.ini中启用extension=php_mssql.dll (适合php5.3之前版本,php5.3或之后用SQLServerDriverForPHP驱动)
SQLServerDriver连接:
$serverName = "(local)";
$connectionInfo = array( "Database"=>"数据库名", "UID" => '用户', "PWD" => '密码');
$conn = sqlsrv_connect( $serverName, $connectionInfo);
if( $conn )
{
echo "Connection established.\n";
}
else
{
echo "Connection could not be established.\n";
die( print_r( sqlsrv_errors(), true));
}
.....................
sqlsrv_close( $conn);
http://www.microsoft.com/sqlserver/2005/en/us/PHP-Driver.aspx