2015-07-20 33 views
0

我已經看了一個相關的答案這個問題的負載,但..解決方案仍然沒有爲我工作!我的代碼在localhost測試環境內工作正常,但不在生產環境中。訪問拒絕mysqli時推送到生產服務器

這裏是我的代碼:

<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]:(一千〇四十五分之二萬八):訪問 拒絕用戶「普羅米修斯'@'****。manchester.mpl.local'(使用 password:YES) /storage/www/z-ingenium/application/views/scripts/reports/clearance-expires.phtml on line 7 Failed連接到MySQL:訪問拒絕用戶 'prometheus'@solutions.manchester.mpl.local'(使用密碼:是)

+3

看起來你沒有在你的生產服務器上設置密碼。嘗試刪除密碼。 –

+1

您是否從命令行驗證了MySQL連接? (意識到在發佈之前您可能已經從源代碼中刪除密碼)。 –

+0

您的數據庫是否在另一臺主機上?數據庫服務器的「綁定地址」是否配置爲允許遠程主機?默認情況下,它只設置爲允許從本地主機。 – Rvanlaak

回答

0

密碼$db['password'] = '';爲mysql用戶[email protected]是錯誤的。 生產模式中是否有本地地址?

+1

嗨@AMNBandra嗨@AMNBandra我忘了密碼發佈在這裏在我的代碼有一個密碼目前 –

+0

謝謝@William Turrell生產服務器和localhost是在同一個域內的地址是正確的 –

+2

我也通過命令行檢查驗證 –

0

我很抱歉遲到的迴應! ..我現在已經解決了這個問題!通過檢查application.ini文件,生產數據庫的憑證位於那裏,與我使用的憑據不同。糾正這個信息後,它現在完美:)