2014-05-12 64 views
0

我張貼this幾個月前關於把我的數據庫信息在ini文件和拉動這些信息在我的代碼。那麼,它目前正在另一個網站上使用相同(很好,相似)的代碼,這次我得到了一個致命錯誤。代碼是相同的,應該像另一個一樣工作。但事實並非如此。我甚至將ini文件移動到同一個目錄中 - 以防出現問題。致命錯誤未捕獲的異常無法打開INI文件

<?php 

function getConnected() 
{ 
    $file = "connection.ini"; 
    if (!$settings = parse_ini_file($file, TRUE)) throw new exception('Unable to open ' . $file . '.'); 

    $host = $settings['mysqli']['default_host']; 
    $user = $settings['mysqli']['default_user']; 
    $pass = $settings['mysqli']['default_pw']; 
    $dbs = $settings['mysqli']['default_db']; 

    $con = mysqli_connect($host,$user,$pass,$dbs); 
    return $con; 
} 

//MYSQLI CONNECTION 
$con = getConnected(); 

//CONNECTION CHECK 
if (mysqli_connect_errno()) { 
    printf("Connect failed: %s\n", mysqli_connect_error()); 
    exit(); 
} 
?> 

這是錯誤我得到:

Fatal error: Uncaught exception 'Exception' with message 'Unable to open connection.ini.' in /home/ThisDirectory/public_html/dev/classes/connection.php:6 Stack trace: #0 /home/ThisDirectory/public_html/dev/classes/connection.php(18): getConnected() #1 /home/ThisDirectory/public_html/dev/classes/tables.php(2): include('/home/ThisDirectory/p...') #2 /home/ThisDirectory/public_html/dev/setup/index.php(2): include('/home/ThisDirectory/p...') #3 {main} thrown in /home/ThisDirectory/public_html/dev/classes/connection.php on line 6

你認爲它可能會像設置/權限問題?我試圖給它777,但它仍然沒有工作。

想法?

+0

我已經嘗試了很多步驟,而且我還沒有完成。我不知道是否有設置問題或我稱之爲'include'connection.php';'它應該是別的嗎?再次,這與我對另一個項目所做的幾乎完全相同,我很難過。任何幫助,將不勝感激。 –

回答

0

好的,我明白了......問題是我在DB上的密碼有特殊字符,沒有任何「逃生」字符。嗯是的。全部固定。我想我是訓練中的天才。

相關問題