代碼如下
<?php
echo 'hello1';
$conn = @new COM("ADODB.Connection") or die ("ADO Connection faild.");
echo 'hello2';
$connstr = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=".realpath("db.mdb");
//$connstr = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=".Server.MapPath("db.mdb");
echo 'hello3';
$conn->Open($connstr);
echo 'hello4';
$rs = @new COM("ADODB.RecordSet");
echo 'hello5';
$rs->Open("select * from users",$conn);
echo 'hello6';
while(!$rs->eof){
echo $rs->Fields["name"]->Value;
echo "<br/>";
$rs->Movenext(); //將記錄集指針下移
}
$rs->close();
?>
發現只輸出 hello1而不輸出hello2,
說明
$conn = @new COM("ADODB.Connection") or die ("ADO Connection faild.");
並沒有執行成功。
弄了很長時間不知道是什麼問題,大家看看?
這樣吧,多個@是個幾意思?
$conn = new COM("ADODB.Connection");