小编Clo*_*ife的帖子

CodeIgniter form_validation-> run()总是返回false?

我是新手CodeIgniter,我一直在尝试实现表单提交功能,但每当我按"提交"表单页面时,只需刷新并且数据库不会更新!似乎$this->form_validation->run()总是返回假,但我不知道为什么.

所述控制器的功能如下:

public function write_prof_review($prof_id)
    {
        $this->load->model('Queries');
        // form stuff here
        $this->load->helper('form');
        $this->load->library('form_validation');

        $data['prof_id'] = $prof_id;
        if($this->form_validation->run() == FALSE){
            $this->load->view('create_prof_review', $data);
        }
        else {
            $this->Queries->submit_prof_review($prof_id, $this->USERID);
            $this->load->view('form_submitted');
        }       
    }
Run Code Online (Sandbox Code Playgroud)

这里是功能submit_prof_review()的模型:

function submit_prof_review($prof_id, $user_id)
    {
        $data = array(
            'course_code' => $this->input->post('course_code'),
            'easiness' => $this->input->post('easiness'),
            'helpfulness' => $this->input->post('helpfulness'),
            'clarity' => $this->input->post('clarity'),
            'comment' => $this->input->post('comment')
        );

    $average = round((($data['easiness'] + $data['helpfulness'] + $data['clarity'])/3),2);
    date_default_timezone_set('Asia/Hong_Kong');
    $date = date('m/d/Y h:i:s a', time());

    $data['average'] = $average;
    $data['date'] = …
Run Code Online (Sandbox Code Playgroud)

php codeigniter codeigniter-form-helper

3
推荐指数
1
解决办法
3万
查看次数

javascript函数未定义

我设置了名为"drawEverything()"的函数来运行onload,但是该函数没有运行,我在Firebug中得到一个错误,说"drawEverything未定义"?事情是,我确实定义了它!

我搜索了这个问题,大部分时间都是由于某种语法错误,但我看了一遍,却找不到任何语法错误.

我的代码如下:

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Test</title>
<link rel=stylesheet href="style.css" type="text/css">
</head>

<script type="text/javascript">

var new_x = 110;
var new_y = 150;
function drawEverything(){
    var temp_x = new_x;
    var temp_y = new_y;

    var c = document.getElementById("myCanvas");
    var ctx = c.getContext("2d");
    for (int i = 0; i < 5; i++){
        ctx.beginPath();
        ctx.arc(temp_x,temp_y,20,0,2*Math.PI);

        ctx.stroke();
        if ((i < 3) || (i == 4)){
            temp_x += 40;
        }
        else if (i == 3){
            temp_y += 20;
            temp_x -= …
Run Code Online (Sandbox Code Playgroud)

html javascript

2
推荐指数
1
解决办法
1万
查看次数