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

ThesecrettokeepingaPHP-poweredwebsiterunningsmoothlyunderheavyloadinvolvesseveralkeystrategies:1)ImplementopcodecachingwithOPcachetoreducescriptexecutiontime,2)UsedatabasequerycachingwithRedistolessendatabaseload,3)LeverageCDNslikeCloudflareforservin

You should care about DependencyInjection(DI) because it makes your code clearer and easier to maintain. 1) DI makes it more modular by decoupling classes, 2) improves the convenience of testing and code flexibility, 3) Use DI containers to manage complex dependencies, but pay attention to performance impact and circular dependencies, 4) The best practice is to rely on abstract interfaces to achieve loose coupling.

Yes,optimizingaPHPapplicationispossibleandessential.1)ImplementcachingusingAPCutoreducedatabaseload.2)Optimizedatabaseswithindexing,efficientqueries,andconnectionpooling.3)Enhancecodewithbuilt-infunctions,avoidingglobalvariables,andusingopcodecaching

ThekeystrategiestosignificantlyboostPHPapplicationperformanceare:1)UseopcodecachinglikeOPcachetoreduceexecutiontime,2)Optimizedatabaseinteractionswithpreparedstatementsandproperindexing,3)ConfigurewebserverslikeNginxwithPHP-FPMforbetterperformance,4)

APHPDependencyInjectionContainerisatoolthatmanagesclassdependencies,enhancingcodemodularity,testability,andmaintainability.Itactsasacentralhubforcreatingandinjectingdependencies,thusreducingtightcouplingandeasingunittesting.

Select DependencyInjection (DI) for large applications, ServiceLocator is suitable for small projects or prototypes. 1) DI improves the testability and modularity of the code through constructor injection. 2) ServiceLocator obtains services through center registration, which is convenient but may lead to an increase in code coupling.

PHPapplicationscanbeoptimizedforspeedandefficiencyby:1)enablingopcacheinphp.ini,2)usingpreparedstatementswithPDOfordatabasequeries,3)replacingloopswitharray_filterandarray_mapfordataprocessing,4)configuringNginxasareverseproxy,5)implementingcachingwi

PHPemailvalidationinvolvesthreesteps:1)Formatvalidationusingregularexpressionstochecktheemailformat;2)DNSvalidationtoensurethedomainhasavalidMXrecord;3)SMTPvalidation,themostthoroughmethod,whichchecksifthemailboxexistsbyconnectingtotheSMTPserver.Impl


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

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 Chinese version
Chinese version, very easy to use

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

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

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.
