ต้องการ connect mssql ไปอีกเครื่องserver นึง แต่ เออเร่อ Fatal error: Call to undefined function mssql_connect()
ต้องการ connect mssql ไปอีกเครื่องserver นึง แต่ เออเร่อ Fatal error: Call to undefined function mssql_connect()
ลองทำตามกระทู้ต่างๆแล้วก็ไม่ได้ผล
เอา ntwdblib.dll ไปไว้ใน
\xampp\php
\xampp\apache\bin
C:\Windows
C:\Windows\System32
C:\Windows\SysWOW64
เอา php_mssql.dll ไปไว้ใน
xampp\php\ext
แก้ extension=php_mssql.dll php.ini ก็แล้ว
restart apache ก็แล้ว
Code (PHP)
<?php
$host = "ไอพีอื่นที่ลง mssql server ไว้ ,1433" ; ใช้ port 1433
$username = "bn_api_user2" ;
$password = "123456" ;
$db = test"" ; ฐานข้อมูล อีกเซิร์ฟนึง
$connect = mssql_connect($host,$username,$password) ;
/* add by kergrit(redthird.com) for compatible global variable off/on php.ini */
mssql_select_db($db) ;
?>
<?php
$danger = '<div align="center" class="alert alert-danger">';
$success = '<div align="center" class="alert alert-success">';
$info = '<div align="center" class="alert alert-info"><h5><i class="icon-info-sign"></i>';
$iconok = '<i class="icon-ok"></i>';
$iconerror = '<i class="icon-remove"></i>';
?>
อันนี้เป็น logs ที่ apache แจ้ง error
Code (PHP)
PHP Warning: PHP Startup: mssql: Unable to initialize module\nModule compiled with module API=20090626, debug=0, thread-safety=1\nPHP compiled with module API=20060613, debug=0, thread-safety=1\nThese options need to match\n in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library 'D:\\xampp\\php\\ext\\php_pdo_mssql.dll' - The specified procedure could not be found.\r\n in Unknown on line 0
[Thu Aug 07 18:41:58 2014] [notice] Child 896: Child process is running
[Thu Aug 07 18:41:58 2014] [notice] Child 896: Acquired the start mutex.
[Thu Aug 07 18:41:58 2014] [notice] Child 896: Starting 250 worker threads.
[Thu Aug 07 18:41:58 2014] [notice] Child 896: Starting thread to listen on port 443.
[Thu Aug 07 18:41:58 2014] [notice] Child 896: Starting thread to listen on port 80.
Tag : MySQL, Ms SQL Server 2005, Ms SQL Server 2008, Windows, Web Service
Date :
2014-08-07 18:55:30
By :
wanlop8822
View :
1367
Reply :
2
เปลี่ยนไปใช้ PDO ก็ได้ครับ
Code (PHP)
<html>
<head>
<title>ThaiCreate.Com PHP & Windows Azure (SQL Azure)</title>
</head>
<body>
<?
$serverName = "tcp:bc6hela9fr.database.windows.net,1433";
$userName = 'thaicreate-user@bc6hela9fr';
$userPassword = 'password';
$dbName = "thaicreate-db";
$connectionInfo = array("Database"=>$dbName, "UID"=>$userName, "PWD"=>$userPassword, "MultipleActiveResultSets"=>true);
sqlsrv_configure('WarningsReturnAsErrors', 0);
$conn = sqlsrv_connect( $serverName, $connectionInfo);
$strSQL = "SELECT * FROM customer";
$stmt = sqlsrv_query($conn, $strSQL);
?>
<table width="600" border="1">
<tr>
<th width="91"> <div align="center">CustomerID </div></th>
<th width="98"> <div align="center">Name </div></th>
<th width="198"> <div align="center">Email </div></th>
<th width="97"> <div align="center">CountryCode </div></th>
<th width="59"> <div align="center">Budget </div></th>
<th width="71"> <div align="center">Used </div></th>
</tr>
<?
while($row = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_ASSOC))
{
?>
<tr>
<td><div align="center"><?=$row["CustomerID"];?></div></td>
<td><?=$row["Name"];?></td>
<td><?=$row["Email"];?></td>
<td><div align="center"><?=$row["CountryCode"];?></div></td>
<td align="right"><?=$row["Budget"];?></td>
<td align="right"><?=$row["Used"];?></td>
</tr>
<?
}
?>
</table>
<?
sqlsrv_close($conn);
?>
</body>
</html>
Date :
2014-08-08 10:00:44
By :
mr.win
Load balance : Server 05