base_url()和site_url()在实时服务器中不起作用

时间:2015-05-06 06:49:17

标签: php codeigniter

我正在使用codeigniter。我试图在表单操作中调用控制器函数。

<form action="<?php echo site_url("Welcome/InsertValue");?>" method="post" name="frm1"  >

这完全适用于本地服务器。但在实时服务器中显示404 Page Not Found错误。

这是我的控制器功能

function InsertValue(){

        $this->load->database();

            /*db(Insert)*/
        $this->load->model("get_db");

        $data = array(
        'p_name' => $this->input->post('pname'),
        'y_addr' => $this->input->post('addr'),
        'rating' => $this->input->post('rating'),
        'apartment' => $this->input->post('apartment'),
        'web_url' => $this->input->post('website'),
        'p_manage_qu' => $this->input->post('pcompany'),
        'country' => $this->input->post('country'), 
        'city' => $this->input->post('city'),
        'p_addr' => $this->input->post('paddr'),
        'zip' => $this->input->post('zip'),
        'contact' => $this->input->post('contact')
    );

        $this->get_db->insert1($data);
        /*echo "new row added";*/
        /*db(Insert)*/

        $this->load->helper('url');
        $this->load->view('supplier/property');
    }

1 个答案:

答案 0 :(得分:3)

由于控制器名称,路径等情况,在localhost上工作而不在live linux主机上运行的东西是99%。

当您使用Windows或MAC进行开发时,他们并不关心案例。 Linux确实。

所以,如果您的Live Host是基于Linux的...... 您的欢迎控制器在URL中应为小写。

顺便说一下:对于命名方法,例如insert_value或camel case insertValue,使用小写通常是正常的。但这不应该是一个节目阻止 - 它更像是一种编码风格的惯例。 CI建议使用下划线进行单词分隔的小写,即insert_value。

<?php echo base_url();?>index.php/welcome/InsertValue

网址中的欢迎控制器名称为欢迎(全部小写)和不欢迎

另外,请始终查看Pages Source中生成的链接等,以确保它看起来不错!从您的浏览器。这通常是右键单击 - 查看源(取决于您使用的浏览器)。或者你可以在F11中查看面板中的源或右键单击Inspect Element ...你需要知道如何查看正在生成的内容并在遇到问题时尝试一下。

希望有所帮助。

相关问题