如何将sql连接到php

发布于 2024-12-25 12:11:42 字数 326 浏览 0 评论 0原文

我已将 sql 连接到 php 但显示错误

调用未定义的函数mssql_connect()

<?php
  $myServer = "sql";
  $myUser = "ste";
  $myPass = "the";
  $myDB = "SQL2005"; 
  $dbhandle = mssql_connect($myServer, $myUser, $myPass)
  or die("Couldn't connect to SQL Server on $myServer"); 
?>

I had connect sql to php but it shows error

Call to undefined function mssql_connect()

<?php
  $myServer = "sql";
  $myUser = "ste";
  $myPass = "the";
  $myDB = "SQL2005"; 
  $dbhandle = mssql_connect($myServer, $myUser, $myPass)
  or die("Couldn't connect to SQL Server on $myServer"); 
?>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

二货你真萌 2025-01-01 12:11:42

根据 文档,您尝试使用的 MS SQL 扩展不再是支持,您应该使用替代方案。

According to the documentation, the MS SQL extension you are trying to use is no longer supported and you should use an alternative.

心安伴我暖 2025-01-01 12:11:42

mssql_connect

似乎是一个拼写错误

mssql_connect

Appears to be a typo

橘寄 2025-01-01 12:11:42

检查您的 phpinfo() 并确保启用 mssql 扩展。请参阅 PHP.net

Check your phpinfo() and make sure the mssql extension is enabled. See PHP.net

习惯成性 2025-01-01 12:11:42

在您的“php.ini”中,搜索

extension=php_mssql.dll

并取消注释(如果已注释)。然后检查是否可以使其工作。

in your "php.ini", search for

extension=php_mssql.dll

and uncoment if its already commented. Then check if you can get it working.

思慕 2025-01-01 12:11:42

以下链接应该可以帮助您解决此问题: http://www.phpfreaks.com /forums/index.php?topic=197064.0

具体来说:

要使 mssql 扩展正常工作,所有
以下必须正确 -

您要更改的 php.ini 必须是 php 正在使用的 php.ini。

php_mssql.dll 必须位于 ext 文件夹中。

php.ini中的extension_dir设置必须设置为ext文件夹,
像extension_dir = c:\php\ext

要使对 php.ini 所做的更改生效,您必须停止并启动
IIS Web 服务。在服务控制面板中执行此操作或重新启动
你的电脑。只需停止并启动 IIS 中的网站
管理控制台还不够。

mssql 要求:ntwdblib.dll 在 Windows 路径上可用。它
最好将 php 文件夹添加到 Windows PATH 而不是移动
周围的任何文件。重新登录或重新启动计算机以获取任何更改
使Windows PATH语句生效。

php 文件夹必须设置适当的权限以允许 IIS 用户
帐户读取php文件夹和ext文件夹中的文件。

这个: http://php.net/manual/en/function.mssql-connect .php 是 mssql_connect() 的文档,也可能有所帮助。

The following link should help you to resolve this: http://www.phpfreaks.com/forums/index.php?topic=197064.0

Specifically:

For the mssql extension to work, all of the
following must be true -

The php.ini that you are changing must be the one that php is using.

The php_mssql.dll must be in the ext folder.

The extension_dir setting in php.ini must be set to the ext folder,
something like extension_dir = c:\php\ext

To get changes made to php.ini to take effect, you must stop and start
the IIS web service. Do this in the services control panel or reboot
your computer. Just stopping and starting the web site in the IIS
management console is not enough.

mssql requires: ntwdblib.dll to be available on the Windows PATH. It
is better to add the php folder to the Windows PATH instead of moving
any files around. Re-logon or reboot your computer to get any changes
made to the Windows PATH statement to take effect.

The php folder must have proper permissions set to allow the IIS user
account to read the files in the php folder and in the ext folder.

This: http://php.net/manual/en/function.mssql-connect.php is the documentation for mssql_connect() also which may help.

£噩梦荏苒 2025-01-01 12:11:42

检查一下 php_mssql.dll 文件是否存在于 wamp\php\ext 位置。

hey check whether the php_mssql.dll file is present at wamp\php\ext location or not.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文