Home > php教程 > php手册 > body text

PHP连接MSSQL及使用过程中的错误

WBOY
Release: 2016-06-13 10:44:17
Original
1628 people have browsed it

环境 PHP5.2.6
SQL2005 标准版
SERVER2003 SP2
 
 
1:SQL2005 文件损坏,无法正常使用 然后,未完全卸载干净 结果:重装系统,方便快捷。
2:PHP配置支持MSSQL出了些小问题 mssql_connect连接方式 无法连接 只能使用ODBC方式连接
解决办法 在SYSTEM32中加入NTWDBLIB.DLL PHP自带是连接7.0的对于2005来说无效
据说本DLL可在SQL安装文件中找到 - -!

附两种连接方式的代码:
//mssql_connect连接方式
//Server and login Info
$SERVER = 'IP';
$USER_NAME = "USER";
$USER_PASS = "PASS";
$DATABASE = "DBNAME";

//Connecting to the server
$CONN = mssql_connect($SERVER, $USER_NAME, $USER_PASS)or die ("Can't connect to Microsoft SQL Server");

//Selecting the database
$connection = mssql_select_db($DATABASE, $CONN)or die ("Can't connect to Database");
if($connection)   printf   ("Connected    successfully");   
?>
//ODBC连接方式
$connection_string = 'DRIVER={SQL Server};SERVER=IP;DATABASE=DBNAME';
$user = 'USER';
$pass = 'PASS';
$connection = odbc_connect( $connection_string, $user, $pass )    OR    die("??");
if($connection)   printf   ("Connected    successfully");   
?>
作者“成长足迹”

source:php.cn
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template