2017-06-09 116 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