Home >Backend Development >PHP Tutorial >PHP connection mssql database configuration and demonstration code_PHP tutorial
Open the PHP configuration file php.ini, find;extension=php_mssql.dll and remove the semicolon in front. 2. Find mssql.secure_connection = Off and change it to mssql.secure_connection = On. 3. Copy the two files php_mssql.dll and ntwdblib.DLL in the PHP folder to the C:windowssystem32 folder.
php tutorial connect mssql database tutorial configuration and demonstration code
/*
Open the php configuration file php.ini, find;extension=php_mssql.dll and remove the semicolon in front.
2. Find mssql.secure_connection = off and change it to mssql.secure_connection = on.
3. Copy the two files php_mssql.dll and ntwdblib.dll in the php folder to the c:windowssystem32 folder
----Here, copying ntwdblib.dll to c:windowssystem32 failed because the dll file already exists in this directory.
I restart apache,
*/
$hostname="10.4.250.20";
$dbuser="hr";
$dbpasswd="946138";
$dbname="hr";
$conn = mssql_connect($hostname,$dbuser,$dbpasswd) or die("Database connection error!");
mssql_select_db($dbname,$conn);
$sql = " select * from pip_staff_s where cstaffid ='z797' ";
$rowset=mssql_query($sql,$conn);
$rowcnt=mssql_num_row($rowset);
echo " rows ";
echo $rowset;
echo " end ";