
これが私のコードです:
<?php
$connect = odbc_connect('Test','EWF','EWF');
$query = "SELECT * FROM [Sheet1$];";
$result = odbc_exec($connect,$query);
$row = odbc_fetch_array($result);
if (!$row){
$test = odbc_result($row,'Column');
echo $test;
}
空白ページが表示されますが、データがありません?? ?>
答え1
これが実際に使用している接続文字列である場合、それは間違っています。使用しているドライバーを宣言し、ドライバーに必要な引数を提供する必要があります。次に例を示します。
$excelFile = "your file name here.xls";
$excelDir = "path\to\that\file\";
odbc_connect("Driver={Microsoft Excel Driver (*.xls)};DriverId=790;Dbq=$excelFile;DefaultDir=$excelDir" , '', '');
PHP ドキュメント: https://www.php.net/manual/en/function.odbc-connect.php