donglu5047 2013-06-25 02:35
浏览 24

MSSQL连接代码语法错误?

Below is my connection string for mssql server its named SKPI-APPS1. I know mssql is to be removed from php but i just need to finish this simple webpage for my company since all of their webpages are made from the old php version so they cannot just easily switch the new php version.

The code below doesn't display anything when I'm trying it with localhost/login.php doesn't even display errors.

Can anyone define what the problem is coming from?

<?php
$myServer = "SKPI-APPS1";
$myUser = "sa";
$myPass = "";
$myDB = "AFS";

//connection to the database
$dbhandle = mssql_connect($myServer, $myUser, $myPass)
or die("Couldn't connect to SQL Server on $myServer");

//select a database to work with
$selected = mssql_select_db($myDB, $dbhandle)
or die("Couldn't open database $myDB");

//close the connection
mssql_close($dbhandle);
?> 
  • 写回答

1条回答 默认 最新

  • dongyong5912 2013-06-25 02:49
    关注

    Please follow the steps given below to connect MSSQL with php:

    1. Settings related to your php.ini file:

      a) search the variable mssql.secure_connection in your php.ini file and put it to on mode if its off
      b) remove comment from the dll extention php_mssql.dll (i.e. remove the ; from the front of the extention )

    2. Settings related to the dll files. Download a file name ntwdblib.dll from the internet. you can download it from here or can search on internet for that. copy the downloaded dll to the apache/bin directory and for IIS copy it to the php extention directory (if path not known can be found in php.ini for variable extension_dir) also you need to have your php_mssql.dll in your php extension directory. if its not present please download it and copy it to the default php extension directory.

    3. restart all your services (i.e. php and apache or iis) and you can use the script given below to connect to your SQL Server.

    Credit to http://samsami2u.wordpress.com/2008/06/30/how-to-connect-mssql-with-php/

    评论

报告相同问题?

悬赏问题

  • ¥20 数学建模,尽量用matlab回答,论文格式
  • ¥15 昨天挂载了一下u盘,然后拔了
  • ¥30 win from 窗口最大最小化,控件放大缩小,闪烁问题
  • ¥20 易康econgnition精度验证
  • ¥15 msix packaging tool打包问题
  • ¥28 微信小程序开发页面布局没问题,真机调试的时候页面布局就乱了
  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能