search
HomeBackend DevelopmentPHP Tutorial为何小弟我的php链接数据库老成功呢

为何我的php链接数据库老成功呢?
我的环境,Windows 2008,SQL Server 2000,php5.2.17.

我的链接数据库的代码如下:

echo "
\n进入mssql
\n";

//包含数据库信息的文件
include('db/mssql.inc');

//链接成功,返回一个链接标识,失败返回FALSE
$my_conn = mssql_connect($db_server,$db_user_name,$db_password,true);

if(!$my_conn)
{
//相当于exit
die('链接数据库失败!');
}
else
{
echo "链接SQL Server成功!
\n";


//关闭SQL链接
mssql_close($my_conn);
}
echo "离开mssql
\n
\n";
?>

其中,包含数据库的信息的文件mssql.inc,我现在把数据库的用户和密码都改成不正确的了,
还是显示链接正常。
显示如下:
进入mssql
链接SQL Server成功!
离开mssql


这是为什么呢???
谢谢高手指点,我刚开始学习哦。

------解决方案--------------------
我想....那只能说明你的判断条件正好反掉了....也就是说你至今为止从没成功连接到db过..

看看你php里的error_log里有什么。
------解决方案--------------------
不排除是你的浏览器缓存作怪
------解决方案--------------------
连接根本就没关嘛!
------解决方案--------------------
好蛋疼 有人问 为什么老是不成功 现在变成 老是成功
看起来没什么问题 在if(!$my_conn) 前 var_dump($my_conn); 看下输出什么
------解决方案--------------------

$my_conn = mssql_connect($db_server,$db_user_name,$db_password,true);
改成
$my_conn = mssql_connect($db_server,$user,$password,true);
看看还正确吗?
------解决方案--------------------
认证的修改在sql server里
------解决方案--------------------
晕死...

太能搞了你,mssql可以设置帐号的验证方式,注意看下mssql的工具那,具体怎么弄我已经不记得了.你继续鼓捣
------解决方案--------------------
新建一个SqlServer用户,重新试验一下,既可以对比,又可以测试成功与否。

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
php怎么连接mssql数据库php怎么连接mssql数据库Oct 23, 2023 pm 12:02 PM

php连接mssql数据库的方法有使用PHP的MSSQL扩展、使用PDO等。详细介绍:1、使用PHP的MSSQL扩展方法,确保PHP安装了MSSQL扩展。可以在PHP配置文件(php.ini)中检查是否启用了mssql扩展;2、使用PDO方法,确保PHP安装了PDO扩展。可以在PHP配置文件(php.ini)中检查是否启用了pdo_sqlsrv扩展。

Ubuntu安装PHP并配置MSSQL连接的详细指南Ubuntu安装PHP并配置MSSQL连接的详细指南Feb 29, 2024 am 11:15 AM

Ubuntu是一款流行的开源操作系统,常用于服务器运行。在Ubuntu上安装PHP并配置MSSQL连接是许多开发者和系统管理员经常需要做的操作之一。本文将为读者提供一份详细的指南,步骤包含安装PHP、设置Apache、安装MSSQLServer等内容,并附上具体的代码示例。第一步:安装PHP及相关扩展首先,我们需要安装PHP及其相关扩展,以便支持PHP连接

如何安装、卸载、重置Windows服务器备份如何安装、卸载、重置Windows服务器备份Mar 06, 2024 am 10:37 AM

WindowsServerBackup是WindowsServer操作系统自带的一个功能,旨在帮助用户保护重要数据和系统配置,并为中小型和企业级企业提供完整的备份和恢复解决方案。只有运行Server2022及更高版本的用户才能使用这一功能。在本文中,我们将介绍如何安装、卸载或重置WindowsServerBackup。如何重置Windows服务器备份如果您的服务器备份遇到问题,备份所需时间过长,或无法访问已存储的文件,那么您可以考虑重新设置WindowsServer备份设置。要重置Windows

Ubuntu环境下安装PHP支持MSSQL数据库的步骤详解Ubuntu环境下安装PHP支持MSSQL数据库的步骤详解Feb 29, 2024 am 10:39 AM

在Ubuntu环境下安装PHP支持MSSQL数据库的步骤详解在开发Web应用程序时,经常会遇到需要连接MicrosoftSQLServer(MSSQL)数据库的情况。在Ubuntu环境下,要实现PHP对MSSQL数据库的连接,需要安装相关的软件以及配置适当的设置。接下来,将详细介绍在Ubuntu环境下安装PHP支持MSSQL数据库的步骤,并提供具体的代码

Windows Server 2025预览版迎来更新,微软改善Insiders测试体验Windows Server 2025预览版迎来更新,微软改善Insiders测试体验Feb 19, 2024 pm 02:36 PM

在发布WindowsServer的build26040版本之际,微软公布了该产品的官方名称:WindowsServer2025。一同推出的,还有Windows11WindowsInsiderCanaryChannel版本的build26040。有些朋友可能还记得,多年前有人成功将WindowsNT从工作站模式转换为服务器模式,显示微软操作系统各版本之间的共性。尽管现在微软的服务器操作系统版本和Windows11之间有明显区别,但关注细节的人可能会好奇:为什么WindowsServer更新了品牌,

怎么修改Nginx版本名称伪装任意web server怎么修改Nginx版本名称伪装任意web serverMay 14, 2023 pm 09:19 PM

如何修改nginx默认的名称,可以稍微的伪装一下,也可以装x一般来说修改3个位置,一个是nginx.h、另一个是ngx_http_header_filter_module.c、还有一个ngx_http_special_response.c。提示:一般修改都是在nginx编译之前修改,修改完了之后需要重新编译代码如下:scr/core/nginx.conf#definenginx_version"1.4.7"#definenginx_ver"nginx/"n

php提交表单通过后,弹出的对话框怎样在当前页弹出,该如何解决php提交表单通过后,弹出的对话框怎样在当前页弹出,该如何解决Jun 13, 2016 am 10:23 AM

php提交表单通过后,弹出的对话框怎样在当前页弹出php提交表单通过后,弹出的对话框怎样在当前页弹出而不是在空白页弹出?想实现这样的效果:而不是空白页弹出:------解决方案--------------------如果你的验证用PHP在后端,那么就用Ajax;仅供参考:HTML code<form name="myform"

Ubuntu下安装PHP并连接MSSQL数据库的完整教程Ubuntu下安装PHP并连接MSSQL数据库的完整教程Feb 29, 2024 am 11:18 AM

在Ubuntu操作系统下安装PHP并连接MSSQL数据库是许多开发者和系统管理员所需要掌握的技能之一。本文将提供一个详细的教程,包括安装PHP、安装MSSQL服务器端驱动程序、配置PHP连接MSSQL数据库,并提供相应的代码示例。第一部分:安装PHP首先,我们需要安装PHP及相关的扩展,以便能够连接MSSQL数据库。在终端中输入以下命令来安装PHP及必要的扩

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.