我正在使用xampp, PHP, and MSSQL
。我需要从SELECT
db做一个MSSQL
语句。目前我只与MSSQL
建立了连接,发现很难从数据库中对SELECT
发出dbo.My_TABLE
声明。
我的代码如下;
,错误我得到Fatal error: Call to undefined function sqlsrv_exec() i
$ser = "COMP\DEF";
$co = array( "Database"=>"IST");
$conn = sqlsrv_connect( $seR, $CO);
if(! $conn ) {
echo "failed.";
}
if ($conn)
{
//the SQL statement that will query the database
$query = "select * from dbo.MY_TABLE";
//perform the query
$result=sqlsrv_exec($conn, $query);
//print field name
$colName = sqlsrv_num_fields($result);
for ($j=1; $j<= $colName; $j++)
{
echo "<th>";
echo sqlsrv_field_name ($result, $j );
echo "</th>";
}
//fetch tha data from the database
while(sqlsrv_fetch_row($result))
{
echo "<tr>";
for($i=1;$i<=sqlsrv_num_fields($result);$i++)
{
echo "<td>";
echo sqlsrv_result($result,$i);
echo "</td>";
}
echo "</tr>";
}
echo "</td> </tr>";
echo "</table >";
//close the connection
sqlsrv_close ($conn);
}
?>
答案 0 :(得分:0)