Heim  >  Artikel  >  Backend-Entwicklung  >  PHP连接MSSQL及使用过程中的错误_PHP教程

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

WBOY
WBOYOriginal
2016-07-13 17:45:26839Durchsuche

环境 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");   
?>
作者“成长足迹”

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/478658.htmlTechArticle环境 PHP5.2.6 SQL2005 标准版 SERVER2003 SP2 1:SQL2005 文件损坏,无法正常使用 然后,未完全卸载干净 结果:重装系统,方便快捷。 2:PHP配置支...
Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn
Vorheriger Artikel:php语句_PHP教程Nächster Artikel:php socket讲解与实例_PHP教程