php下使用以下代碼連接并測試
更新時(shí)間:2008年04月09日 23:12:19 作者:
php連接mysql數(shù)據(jù)庫效果
復(fù)制代碼 代碼如下:
<?php
$myServer = "localhost"; //主機(jī)
$myUser = "sa"; //用戶名
$myPass = "password"; //密碼
$myDB = "Northwind";? //MSSQL庫名
$s = @mssql_connect($myServer, $myUser, $myPass)
or die("Couldn't connect to SQL Server on $myServer");
$d = @mssql_select_db($myDB, $s)
or die("Couldn't open database $myDB");
$query = "SELECT TitleOfCourtesy+' '+FirstName+' '+LastName AS Employee ";
$query .= "FROM Employees ";
$query .= "WHERE Country='USA' AND Left(HomePhone, 5) = '(206)'";
$result = mssql_query($query);
$numRows = mssql_num_rows($result);
echo "<h1>" . $numRows . " Row" . ($numRows == 1 ? "" : "s") . " Returned </h1>";
while($row = mssql_fetch_array($result))
{
echo "<li>" . $row["Employee"] . "</li>";
}
相關(guān)文章
用PHP實(shí)現(xiàn)WEB動(dòng)態(tài)網(wǎng)頁靜態(tài)
用PHP實(shí)現(xiàn)WEB動(dòng)態(tài)網(wǎng)頁靜態(tài)...2006-10-10php auth_http類庫進(jìn)行身份效驗(yàn)
前提是要安裝auth類庫和auth_http類庫2009-03-03PHP parse_url 一個(gè)好用的函數(shù)
PHP中一個(gè)好用的函數(shù)parse_url,特別方便用來做信息抓取的分析。2009-10-10用ADODB來讓PHP操作ACCESS數(shù)據(jù)庫的方法
用ADODB來讓PHP操作ACCESS數(shù)據(jù)庫的方法...2006-12-12