我已经看过这个问题的大量相关答案但是......解决方案仍然不适合我!我的代码在localhost测试环境中正常工作,但在生产环境中没有。
这是我的代码:
<h1> Security clearances Due to Expire</h1>
<?php
$db['user'] = 'prometheus';
$db['password'] = '';
$db['host'] = '*****.manchester.mpl.local';
$ingeniumMySQL = new mysqli($db['host'], $db['user'], $db['password'], "ingenium");
if ($ingeniumMySQL->connect_errno) {
echo "Failed to connect to MySQL: " . $ingeniumMySQL->connect_error;
}
$sqlone="SELECT person_security_levels.clearance_expires_date,
person.forename,
person.surname
FROM person_security_levels, person
where person_security_levels.person_id= person.id and person_security_levels.clearance_expires_date between NOW() AND DATE_ADD( NOW() ,
INTERVAL +3 MONTH)
LIMIT 5000
";
$resultone= mysqli_query($ingeniumMySQL,$sqlone);
echo '<table id="magictable" style="float: left; margin: 0 30px 0 50px;">';
echo'<td colspan="3"><h3>Clearances Expiring within Three Months</h3></td>';
echo '</tr>';
echo '<tr>';
echo '<th class="headcolumn">Forename</th>';
echo '<th class="headcolumn">Surname</th>';
echo '<th class="headcolumn">Date Expires</th>';
echo '</tr>';
while ($row = mysqli_fetch_array($resultone)) {
echo "<tr><td>" . $row['forename'] . "</td><td>" . $row['surname'] . "</td><td>" . $row['clearance_expires_date'] . "</td></tr>";
}
echo "</table>";
$sqltwo="SELECT person_security_levels.clearance_expires_date,
person.forename,
person.surname
FROM person_security_levels, person
where person_security_levels.person_id= person.id and person_security_levels.clearance_expires_date between NOW() AND DATE_ADD( NOW() ,
INTERVAL +1 MONTH)
LIMIT 5000";
$resultwo= mysqli_query($ingeniumMySQL,$sqltwo);
echo '<table class="magictable" style="float: left; margin: 0 30px 0 50px;">';
echo'<td colspan="3"><h3>Clearances Expiring within One Month</h3></td>';
echo '</tr>';
echo '<tr>';
echo '<th class="headcolumn">Forename</th>';
echo '<th class="headcolumn">Surname</th>';
echo '<th class="headcolumn"> Date Expires</th>';
echo '</tr>';
while ($rows = mysqli_fetch_array($resultwo)) {
echo "<tr><td>" . $rows['forename'] . "</td><td>" . $rows['surname'] . "</td><td>" . $rows['clearance_expires_date'] . "</td></tr>";
}
echo "</table>";
$sqlthree="SELECT person_security_levels.clearance_expires_date,
person.forename,
person.surname
FROM person_security_levels, person
where person_security_levels.person_id= person.id and person_security_levels.clearance_expires_date between NOW() AND DATE_ADD( NOW() ,
INTERVAL+2 WEEK)
LIMIT 5000";
$resulthree= mysqli_query($ingeniumMySQL,$sqlthree);
echo '<table class="magictable" style="float: left; margin: 0 30px 0 50px;">';
echo'<td colspan="3"><h3>Clearances Expiring within Two Weeks</h3></td>';
echo '</tr>';
echo '<tr>';
echo '<th class="headcolumn">Forename</th>';
echo '<th class="headcolumn">Surname</th>';
echo '<th class="headcolumn"> Date Expires</th>';
echo '</tr>';
while ($roe = mysqli_fetch_array($resulthree)) {
echo "<tr><td>" . $roe['forename'] . "</td><td>" . $roe['surname'] . "</td><td>" . $roe['clearance_expires_date'] . "</td></tr>";
}
echo "</table>";
$sqlfour="SELECT person_security_levels.clearance_expires_date,
person.forename,
person.surname
FROM person_security_levels, person
where person_security_levels.person_id= person.id and person_security_levels.clearance_expires_date between NOW() AND DATE_ADD( NOW() ,
INTERVAL+7 DAY)
LIMIT 5000";
$resultfour= mysqli_query($ingeniumMySQL,$sqlfour);
echo '<table class="magictable" style="float: left; margin: 0 30px 0 50px;">';
echo'<td colspan="3"><h3>Clearances Expiring within Seven Days</h3></td>';
echo '</tr>';
echo '<tr>';
echo '<th class="headcolumn">Forename</th>';
echo '<th class="headcolumn">Surname</th>';
echo '<th class="headcolumn">Date Expires</th>';
echo '</tr>';
while ($roes = mysqli_fetch_array($resultfour)) {
echo "<tr><td>" . $roes['forename'] . "</td><td>" . $roes['surname'] . "</td><td>" . $roes['clearance_expires_date'] . "</td></tr>";
}
mysqli_close($ingeniumMySQL);
?>
我正在查询数据库以在html表中生成结果集。 为指定的用户授予完全权限, 虚拟用户已经创建用于测试不同的帐户,我使用的是最新的mysqli。
以下是制作中显示的错误(感谢任何建议):
警告:mysqli :: mysqli()[mysqli.mysqli] :( 28000/1045):访问权限 否认用户&#39; prometheus&#39; @&#39; ****。manchester.mpl.local&#39; (使用 密码:YES)in /storage/www/z-ingenium/application/views/scripts/reports/clearance-expires.phtml 第7行无法连接到MySQL:用户拒绝访问 &#39;普罗米修斯&#39; @&#39; solutions.manchester.mpl.local&#39; (使用密码:是)
答案 0 :(得分:0)
mysql用户$db['password'] = '';
的密码prometheus@solutions.manchester.mpl.local
错误。
生产模式中是否有本地地址?
答案 1 :(得分:0)
我对迟到的回应道歉! ..我现在已经解决了这个问题!通过检查application.ini文件,生产数据库的凭据存放在那里,这与我使用的不同。在更正此信息后,它现在可以完美地运行:)