为何小弟我的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用户,重新试验一下,既可以对比,又可以测试成功与否。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Methods for php to connect to mssql database include using PHP's MSSQL extension, using PDO, etc. Detailed introduction: 1. Use PHP's MSSQL extension method to ensure that PHP has the MSSQL extension installed. You can check whether the mssql extension is enabled in the PHP configuration file (php.ini); 2. Use the PDO method to ensure that PHP has the PDO extension installed. You can check whether the pdo_sqlsrv extension is enabled in the PHP configuration file (php.ini).

Ubuntu is a popular open source operating system commonly used to run servers. Installing PHP and configuring MSSQL connections on Ubuntu is one of the operations that many developers and system administrators often need to do. This article will provide readers with a detailed guide, including the steps to install PHP, set up Apache, install MSSQLServer, etc., and attach specific code examples. Step 1: Install PHP and related extensions First, we need to install PHP and related extensions to support PHP connections

WindowsServerBackup is a function that comes with the WindowsServer operating system, designed to help users protect important data and system configurations, and provide complete backup and recovery solutions for small, medium and enterprise-level enterprises. Only users running Server2022 and higher can use this feature. In this article, we will explain how to install, uninstall or reset WindowsServerBackup. How to Reset Windows Server Backup If you are experiencing problems with your server backup, the backup is taking too long, or you are unable to access stored files, then you may consider resetting your Windows Server backup settings. To reset Windows

Detailed steps for installing PHP to support MSSQL database in Ubuntu environment. When developing web applications, you often encounter situations where you need to connect to the Microsoft SQL Server (MSSQL) database. In the Ubuntu environment, to connect PHP to the MSSQL database, you need to install relevant software and configure appropriate settings. Next, we will introduce in detail the steps to install PHP to support MSSQL database in Ubuntu environment and provide specific code.

On the occasion of releasing the build 26040 version of Windows Server, Microsoft announced the official name of the product: Windows Server 2025. Also launched is the Windows11WindowsInsiderCanaryChannel version build26040. Some friends may still remember that many years ago someone successfully converted Windows NT from workstation mode to server mode, showing the commonalities between various versions of Microsoft operating systems. Although there are clear differences between Microsoft's current version of the server operating system and Windows 11, those who pay attention to the details may be curious: why Windows Server updated the brand,

How to modify the default name of nginx, you can disguise it a little, or you can install Tip: Generally, modifications are made before nginx is compiled. After modification, the code needs to be recompiled as follows: scr/core/nginx.conf#definenginx_version"1.4.7"#definenginx_ver"nginx/"n

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

Installing PHP and connecting to MSSQL database under the Ubuntu operating system is one of the skills that many developers and system administrators need to master. This article will provide a detailed tutorial, including installing PHP, installing the MSSQL server driver, configuring PHP to connect to the MSSQL database, and providing corresponding code examples. Part One: Install PHP First, we need to install PHP and related extensions to be able to connect to the MSSQL database. Enter the following command in the terminal to install PHP and necessary extensions
