【发布时间】:2014-02-21 12:01:36
【问题描述】:
我有一个代码点火器中的现有项目,并想开始使用杂货杂货。我在最近安装的 wamp、php 5.4、apache 2.4.4 上运行它。
我遵循了基本设置,将文件复制并粘贴到我的代码点火器目录中,并设置了一个控制器以显示具有本教程中的 crud 功能的表,但在查看时出现以下错误:
致命错误:未捕获的异常 'Exception' 带有消息 'On the state “更新”你必须有发布数据' C:\wamp\www...\application\libraries\Grocery_CRUD.php 在第 3185 行
控制器:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Previousqualification extends CI_Controller {
function __construct(){
parent::__construct();
/* Standard Libraries of codeigniter are required */
$this->load->database();
$this->load->helper('url');
/* ------------------ */
$this->load->library('grocery_CRUD');
}
public function test(){
$this->grocery_crud->set_table('previousqualification');
$output = $this->grocery_crud->render();
$this->_crud($output);
}
function _crud($output = null){
$this->load->view('view_previousqualification.php',$output);
}
}
控制器中引用的视图:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<?php
foreach($css_files as $file): ?>
<link type="text/css" rel="stylesheet" href="<?php echo $file; ?>" />
<?php endforeach; ?>
<?php foreach($js_files as $file): ?>
<script src="<?php echo $file; ?>"></script>
<?php endforeach; ?>
<style type='text/css'>
body
{
font-family: Arial;
font-size: 14px;
}
a {
color: blue;
text-decoration: none;
font-size: 14px;
}
a:hover
{
text-decoration: underline;
}
</style>
</head>
<body>
<!-- End of header-->
<div style='height:20px;'></div>
<div>
<?php echo $output; ?>
</div>
<!-- Beginning footer -->
<div>Footer</div>
<!-- End of Footer -->
</body>
</html>
我已经改变了我的基本网址,因为我已经看到这可能是一些类似错误的问题。这没有效果。我确实在 apache 和 .htaccess 中启用了 mod_rewrite 以摆脱 url 中的 index.php - 这可能是一个问题吗?
我一直在查看导致错误的文件 (Grocery_CRUD.php),当我调用 render() 方法时发生这种情况,该方法调用方法 getStateInfo() 调用另一个将状态设置为 6 的方法或'update',然后检查$_POST 变量在getStateInfo() 中是否为空,我猜这是因为它引发了错误。为什么会发生上述任何情况我不确定,但这只是我迄今为止的发现,试图了解到底发生了什么。如果您需要任何信息,请询问。
.htaccess 文件:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /codeIgniter
#Removes access to the system folder by users.
#Additionally this will allow you to create a System.php controller,
#previously this would not have been possible.
#'system' can be replaced if you have renamed your system folder.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
#When your application folder isn't in the system folder
#This snippet prevents user access to the application folder
#Submitted by: Fabdrol
#Rename 'application' to your applications folder name.
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
#Checks to see if the user is attempting to acces a valid file,
#such as an image or css document, if this isn't true it sends the
#request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
# If we don't have mod_rewrite installed, all 404's
# can be sent to index.php, and everything works as normal.
# Submitted by: ElliotHaughin
ErrorDocument 404 /index.php
</IfModule>
【问题讨论】:
-
谢谢,我已经查看了线程,但它并没有解决我的问题。虽然我不理解最后一篇文章中 .htaccess 文件中的 RewriteCond。我需要在那里添加我所有的文件夹吗?当我这样做时,它引导我进入 wamp 启动页面。另外,我尝试注册杂货店论坛问我的问题,但帐户激活电子邮件尚未发送到我的电子邮件地址,因此我在这里发帖。是的,我检查了我的垃圾邮件文件夹并重新发送了激活。
-
我不擅长htaccess。因此,只需发布您的 htaccess 代码和您的 url 详细信息。另外,添加 htaccess 标签。
-
您好@haakym,您是否尝试过不使用 .htaccess 文件来查看它是否适合您?
-
嗨@JohnSkoumbourdis 感谢您的回复。我只是尝试了一下,即完全将文件从项目中取出并在我的项目路径后附加 index.php ,但它产生了相同的错误。唯一不同的是,以前我在使用.htaccess文件时,需要先用大写字母写控制器,这次不用了。我想我可以在干净安装的代码点火器上尝试杂货杂货,将其链接到我的数据库,看看是否有区别。另外,你知道为什么我没有在杂货店论坛上激活我的帐户吗?谢谢
标签: php .htaccess codeigniter grocery-crud