dongshou1856 2018-09-01 15:04
浏览 178

PHP和SQL Server,致命错误:未捕获错误:调用未定义函数sqlsrv_connect()

I'm trying to write a short html page for input username and pwd in order to write some data in my local SQL Server. I can find the error in subject when submitting.

This is the html code:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Form to SQL</title>
</head>
<body>
    <form method="post" action="send.php">
        Username: <input type="text" name="username">
        <br>
        Password: <input type="text" name="password">
        <input type="submit" value="Invia">
    </form>
</body>
</html>

Which is a simple page with no CSS and 2 forms to insert username and password.

The file send.php is the following:

<?php
    $username = filter_input(INPUT_POST, 'username');
    $password = filter_input(INPUT_POST, 'password');
    $conn = sqlsrv_connect('mylocalservername');
    $sql = "insert into dbo.data_input (column1, column2) values
('$username','$password')";
?>

I've just realised I missed the DB name string, but if I'm reading this error correctly, the problem is above since it seems unable to find the function.

I followed the instruction in order to install .dll drivers for PHP and SQL Server, accordingly to my version of PHP (php7ts.dll) they are:

php_pdo_sqlsrv_7_ts_x64.dll

php_sqlsrv_7_ts_x64.dll

Then I looked at the folder in the php.ini file where to put these .dll files:

; Directory in which the loadable extensions (modules) reside.
; http://php.net/extension-dir
; extension_dir = "./"
; On windows:
extension_dir="C:\xampp\php\ext"

So I put these files in the _extension_dir_ folder then I saved the .ini and restart all my system.

Unfortunately, the error still remains the same.

I will appreciate your kind help and sorry for my bad english,

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 keil的map文件中Image component sizes各项意思
    • ¥30 BC260Y用MQTT向阿里云发布主题消息一直错误
    • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
    • ¥15 划分vlan后,链路不通了?
    • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
    • ¥15 Vue3 大型图片数据拖动排序
    • ¥15 Centos / PETGEM
    • ¥15 划分vlan后不通了
    • ¥20 用雷电模拟器安装百达屋apk一直闪退
    • ¥15 算能科技20240506咨询(拒绝大模型回答)