0

我正在使用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); 
} 

?>
4

1 回答 1

0

尝试将其替换为sqlsrv_execute

这是手册和示例:

http://www.php.net/manual/en/function.sqlsrv-execute.php

于 2012-08-28T11:45:51.297 回答