小编Ada*_*tus的帖子

PHPMailer异常错误

我编写了自己的Code Igniter模型来发送电子邮件.一切都很好,直到最近我才开始出现这个错误:

致命错误:无法在第2319行的/home/mysite/public_html/subdir/application/libraries/phpmailer/class.phpmailer.php中重新声明类phpmailerException

我正在使用:

CodeIgniter 2 PHPMailer 5.1

我尝试过以下方法来解决它:

  • 添加"$ mail-> SMTPDebug = 0"以关闭错误.
  • 补充:"$ mail-> MailerDebug = false;"
  • 修改了PHPMailer,仅在打开SMTPDebug时显示错误.
  • 查找并删除任何echo语句
  • 添加了try/catch块尝试添加/删除:$ mail = new PHPMailer(true);

这是我的控制器方法(公司/联系人),它调用我的模型(message_model):

    function contact()
    {
        //Do settings.
        $this->options->task='email';
        $this->options->change = 'sent';
        $this->options->form_validation='';
        $this->options->page_title='Contact Us';

        //Import library
        include_once('application/libraries/recaptcha/recaptchalib.php');//Include recaptcha library.

        //Keys for recaptcha, stored in mainconfig file.
        $this->options->publickey = $this->config->item('recaptcha_public');
        $this->options->privatekey = $this->config->item('recaptcha_private');      

        //Form validation
        $this->form_validation->set_error_delimiters('<div class="error">', '</div>');
        $this->form_validation->set_rules('name_field','Name of problem','trim|required|min_length[3]|max_length[100]');
        $this->form_validation->set_rules('desc_field','Description','trim|required|min_length[10]|max_length[2000]');
        $this->form_validation->set_rules('email_field','Your email address','trim|required|valid_email');
$this->form_validation->set_rules('recaptcha_response_field','captcha field','trim|required|callback__check_recaptcha');

//If valid.
        if( $this->form_validation->run() )
        {
  //Set email contents. …
Run Code Online (Sandbox Code Playgroud)

php codeigniter phpmailer

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

数据表 - 未捕获的类型错误:ba 未定义

我的错误是:

"Uncaught TypeError: ba is undefined"
"https://cdn.datatables.net/v/dt/dt-1.10.22/b-1.6.5/b-print-1.6.5/r-2.2.6/datatables.min.js:119"
Run Code Online (Sandbox Code Playgroud)

没有显示其他错误。我将 Jquery 放在列表中的第一位并检查了所有路径是否有效。我还从数据表站点获得了我认为最合适的链接

<!DOCTYPE html>
<html lang="en">
<head>
    <title>Ajax Filter table</title>    
    <script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>

    <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/v/dt/dt-1.10.22/b-1.6.5/b-print-1.6.5/r-2.2.6/datatables.min.css"/>
    <script type="text/javascript" src="https://cdn.datatables.net/v/dt/dt-1.10.22/b-1.6.5/b-print-1.6.5/r-2.2.6/datatables.min.js"></script>

    <script>
        $(document).ready(function(){
            $('#table').DataTable();
        })
    </script>

</head>
<body>
    <div class="container">
            <table class="table table-striped" id="table">
                <tr>
                    <th>one</th>
                    <th>two</th>
                    <th>three</th>
                    <th>four</th>
                </tr>
                <tr>
                    <td>one</td>
                    <td>two</td>
                    <td>three</td>
                    <td>four</td>
                </tr>                
            </table>
    </div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

javascript jquery datatables

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

带有参数的CodeIgniter回调函数

(编辑:我已经意识到,或许在回调中将数组作为参数传递?)

我正在尝试研究如何将参数传递给CI中的回调函数.我已阅读文档,但除了以下内容之外没有太多内容:

要调用回调,只需将函数名称放在规则中,并使用"callback_"作为规则前缀.如果你需要在回调函数中接收一个额外的参数,只需在方括号之间的函数名之后正常添加它,如:"callback_foo [bar]",然后它将作为你的回调函数的第二个参数传递.

我要做的是创建一个回调函数,检查是否已经选择了一个本来不应该的.因此,如果有人选择"请选择"选项,则不会将其添加到数据库中.任务类型只是一个包含主键和名称字段以及大约10行的表.

控制器 所以这是我的控制器代码(减少):

function Add_Task()
{
  $task_types_get = $this->task_model->Get_Task_Types();//Get available task types.
  $this->options->task_types = $task_types_get->result();
  $not_selectable = array(1);//Non selectable values for select. Added to callback function below for validation. These are pks.

  $this->form_validation->set_rules("task_type","Task Types","required|callback__Not_Selectable[$not_selectable]");

  if($this->form_validation->run())
  {
     //Add to db etc..
  }
}
Run Code Online (Sandbox Code Playgroud)

回调 和我的回调检查是否有东西是不可选的:

function _Not_Selectable($option,$values=array())
{  
  if(in_array($option,$values))//Is the value invalid?
  {
    $this->form_validation->set_message('_Not_Selectable', 'That option is not selectable.');
    return false;
  }
  return true;
}
Run Code Online (Sandbox Code Playgroud)

查看 从模型返回的数据是可以的,但没有验证错误.我的观点如下:

<? $this->load->view('includes/header'); ?>

  <?=form_open();?>

  <div class="form_row">
    <div class="form_field">
      <label for="task_desc">Task …
Run Code Online (Sandbox Code Playgroud)

parameters codeigniter callback

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