 |
ติดปัญหากับ Fatal error: Call to undefined function mssql_connect() in D:\AppServ\www\test.php on line 11 |
|
 |
|
|
 |
 |
|
เอ นั่นมัน PDO นี่หว่า (ของผมมัน PHP5.3 มันจึงไม่มี mssql)
ลองหา
;extension=php_mssql.dll
แล้วเอา ; ออกครับ
|
 |
 |
 |
 |
Date :
2013-05-14 11:58:15 |
By :
cookiephp |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
จะเปลี่ยนไปใช้อย่างอื่นก็ได้ครับ
Odbc + SQL Server
<html>
<head>
<title>ThaiCreate.Com PHP & Windows Azure (SQL Azure)</title>
</head>
<body>
<?
$server = "bc6hela9fr.database.windows.net,1433";
$database = "thaicreate-db";
$user = "thaicreate-user@bc6hela9fr";
$password = "password@123";
$objConnect = odbc_connect("Driver={SQL Server Native Client 10.0};Server=$server;Database=$database;", $user, $password) or die(odbc_errormsg());
$strSQL = "select * from customer;";
$objExec = odbc_exec($objConnect, $strSQL) or die(odbc_errormsg());
?>
<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($objResult = odbc_fetch_array($objExec))
{
?>
<tr>
<td><div align="center"><?=$objResult["CustomerID"];?></div></td>
<td><?=$objResult["Name"];?></td>
<td><?=$objResult["Email"];?></td>
<td><div align="center"><?=$objResult["CountryCode"];?></div></td>
<td align="right"><?=$objResult["Budget"];?></td>
<td align="right"><?=$objResult["Used"];?></td>
</tr>
<?
}
?>
</table>
<?
odbc_close($objConnect);
?>
</body>
</html>
|
 |
 |
 |
 |
Date :
2013-05-14 12:57:07 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
PDO + SQL Server
<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@123';
$dbName = "thaicreate-db";
$conn = new PDO("sqlsrv:server=$serverName ; Database = $dbName", $userName, $userPassword);
$strSQL = "SELECT * FROM customer";
$stmt = $conn->prepare($strSQL);
$stmt->execute();
?>
<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>
<?
$arrValues = $stmt->fetchAll(PDO::FETCH_ASSOC);
foreach ($arrValues as $result){
?>
<tr>
<td><div align="center"><?=$result["CustomerID"];?></div></td>
<td><?=$result["Name"];?></td>
<td><?=$result["Email"];?></td>
<td><div align="center"><?=$result["CountryCode"];?></div></td>
<td align="right"><?=$result["Budget"];?></td>
<td align="right"><?=$result["Used"];?></td>
</tr>
<?
}
?>
</table>
<?
$conn = null;
?>
</body>
</html>
|
 |
 |
 |
 |
Date :
2013-05-14 12:57:32 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
sqlsrv + SQL Server
<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@123';
$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 :
2013-05-14 12:58:02 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|