PHP PDO-连接过多时显示密码 [英] PHP PDO - Showing password when too many connections

查看:59
本文介绍了PHP PDO-连接过多时显示密码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每当我的网站收到太多连接时,就会显示我的数据库信息.

Whenever my website receives too many connections, it's showing my database information.

我专门告诉PDO不要显示PDO::ERRMODE_SILENT的任何错误消息:

I have specifically told PDO not to show any error messages with PDO::ERRMODE_SILENT:

$dsn = "mysql:host=" . $database['host'] . ";dbname=" . $database['db'];
$dbh = new PDO($dsn, $database['user'], $database['pass'], array(PDO::ATTR_PERSISTENT => false));       
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_SILENT); // <== add this line
//echo 'Connected to Database<br/>'; 

此外,我已禁用PHP错误:

Furthermore I have disabled PHP errors:

error_reporting(0);
ini_set('display_errors', '0'); 

当连接过多时,为什么我的PDO向所有人显示我的敏感数据库信息?

Why is my PDO showing my sensitive database information to everyone when there are too many connections?

推荐答案

问题是您正在尝试连接到数据库之前,但您设置了silent属性.因此,在尝试连接期间,PDO仍然可以自由地大声尖叫.您需要指定静默作为连接尝试本身的一部分:

Problem is you're trying to connect to the database BEFORE you set the silent attribute. So during the connection attempt, PDO is still free to scream as loudly as it wants. You need to specify silent as part of the connection attempt itself:

$dbh = new PDO($[..snip..], array(PDO::ATTR_PERSISTENT => false, PDO::ATTR_ERRMODE => PDO::ERRMODE_SILENT));
                                                                 ^^^^^^^^^^^

这篇关于PHP PDO-连接过多时显示密码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆