我正在使用xampp, PHP, and MSSQL
. 我需要SELECT
从数据库做一个声明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);
}
?>