2017-06-09 113 views
0

我在函數調用Codeigniter有一個奇怪的問題。我創建了一個控制器名稱ErrorLog,然後創建一個方法addUpdateError。然後在視圖部分我已經創建了一個鏈接(錨標記)這樣CI控制器方法調用問題

<a style="float:right" href="<?php echo site_url('errorLog/addUpdateError') ?>" title="Add an Error" alt="Add an Error">Add an Error</a> 

我甚至嘗試這種

<a style="float:right" href="errorLog/addUpdateError" title="Add an Error" alt="Add an Error">Add an Error</a> 

而這其中也

<a style="float:right" href="<?php echo base_url(); ?>errorLog/addUpdateError" title="Add an Error" alt="Add an Error">Add an Error</a> 

在瀏覽器網址是http://localhost/projectName/errorLog/addUpdateError我認爲這是有效的。

當我打這個錨標記它給了我這個錯誤

enter image description here

默認控制器正確加載但在那之後,如果我瀏覽到任何地方它不工作。我已正確設置我的base_urlconfig.php和我也設置index_page爲空。我嘗試了所有可能的方式並在Google上搜索。 我甚至試過用Codeigniter的新鮮設置CodeIgniter-2.2.6歡迎使用控制器這個問題仍然出現。

目前我使用PHP 7和笨3和Ubuntu 16.04我只是猜測可能是這個問題是因爲PHP 7

任何幫助,將不勝感激。

+0

你是否已將數據庫驅動程序從'mysql'更新爲'mysqli'? – Bhavin

+0

雅我做到了,但我現在不執行數據庫操作只是簡單的點擊導致問題。 –

+1

嘗試使用index.php可能是.htacess不起作用。試試這個網址:http://localhost/projectname/index.php/errorLog/addUpdateError – Bhavin

回答

0

你的問題是由於.htaccess文件。

嘗試以下步驟,

組配置文件(application/config/config.php)這樣,

$config['index_page'] = ''; 

之後,改變它位於項目的根文件夾不是在應用程序文件夾與.htaccess文件以下代碼。

RewriteEngine on 
RewriteCond $1 !^(index\.php|public|\.txt) 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ index.php?$1 
+0

感謝它的工作。我也嘗試過相同的模式,但不知道我的htaccess文件中可能存在什麼問題。 –

+0

是的,有時會發生。快樂的編碼。 :) – Bhavin