沒有理由你不能有一個腳本,列出了所有你databasenames和登錄憑據,並嘗試依次連接到每個:
$logins = array(
array('dbname' => 'blah', 'user' => 'username1', 'password' => 'password1'),
array('dbname' => 'yuck', ....)
...
);
$failures = array();
foreach ($logins as $login) {
$con = mysql_connect('servername', $login['user'], $login['password']);
if (!$con) {
$failures[] = $login['dbname'] . " failed with " . mysql_error();
continue;
}
$result = mysql_select_db($login['dbname']);
if (!$result) {
$failures[] = "Failed to select " . $login['dbname'] . ": " . mysql_error();
continue;
}
$result = mysql_query("SELECT something FROM sometable");
if (!$result) {
$failures[] = "Faile to select from " . $login['dbname'] . ": " . mysql_error();
continue;
}
if (mysql_num_rows($result) != $some_expected_value) {
$failures[] = "Got incorrect rowcount " . mysql_num_rows($result) . " on " . $login['dbname'];
}
etc....
mysql_close();
}
if (count($failures) > 0) {
echo "Failures found: "
print_r($failures);
}
完美。非常感謝你! – Andi
我剛剛在警報中添加了域名,並在將servername更新到localhost併爲$ some_expected_value提供了一個值之後,這可能無法正常工作。這麼好的解決方案如此之快!就像你在這裏所做的那樣,只寫錯誤就容易多了。我在想什麼? :) 再次感謝。太棒了! – Andi