调用未定义的函数sqlsrv_connect()甚至启用sqlsrv

时间:2014-02-19 23:18:24

标签: php sql-server

我试图将sqlserver连接到php,但我遇到了错误Fatal error: Call to undefined function sqlsrv_connect() in C:\xampp\htdocs\sqlserver1.php on line 6。比我安装PHP驱动程序,我发现here 我配置它.. 当我看到phpinfo()时,在PDO驱动程序中,sqlsrt已启用,但我仍然有错误消息。我正在本地主机上工作,并拥有php版本5.4.7

请帮帮我。有什么问题?

我解决了这个问题,但现在显示的错误信息是:

Warning: sqlsrv_query() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\sqlserver1.php on line 12

Warning: sqlsrv_fetch() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\sqlserver1.php on line 14

Warning: sqlsrv_get_field() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\sqlserver1.php on line 15

这是我的php文件:

<?php

$server = "USER-PC\SQLEXPRESS";
$options = array("UID"=>"", "PWD"=>"", "Database"=>"RESTORANTET");

$conn = sqlsrv_connect($server, $options);

echo $conn;

$sql = "SELECT Emri_Pjates, Cmimi, Pershkrimi FROM dbo.MENU FOR XML PATH";

$stmt = sqlsrv_query($conn, $sql);

sqlsrv_fetch($stmt);
$xml = sqlsrv_get_field($stmt, 0);

?>

你能帮帮我吗?

0 个答案:

没有答案