在我的代码中,他们是一个错误是什么解决方案
遇到PHP错误
严重性:警告
消息:无法修改标头信息 - 已经发送的标头(输出从/home/websites/public_html/application/controllers/user.php:64开始)
文件名:helpers/url_helper.php
行号:546
这是我的代码
function register()
{
$email=$_POST['email'];
$pass=$_POST['pass'];
$cpass=$_POST['cpass'];
$valid = array(
array(
'field' => 'email',
'label' => 'Username(Email)',
'rules' => 'trim|required|valid_email|is_unique[register.email]'
),
array(
'field' => 'pass',
'label' => 'Password',
'rules' => 'trim|required||matches[cpass]|min_length[8]|max_length[30]|'
),
array(
'field' => 'cpass',
'label' => 'Confirm Password',
'rules' => 'trim|required'
)
);
$this->form_validation->set_rules($valid);
$this->form_validation->set_error_delimiters('<div class="error_txt">', '</div>');
if ($this->form_validation->run() == FALSE)
{
echo "error";
redirect('/home/');
}
else
{
$this->load->model('User_model');
$rs=$this->User_model->register($_POST);
redirect('/home/');
}
}
Run Code Online (Sandbox Code Playgroud) 我有一个用户名字段,我不想接受像{*)&(%^%()_}.我需要将哪些内容添加到表单验证规则中?
$this->form_validation->set_rules('user_name' 'User Name', 'trim|required|min_length[4]|xss_clean');
Run Code Online (Sandbox Code Playgroud) 我在以下sql语句中遇到了一些问题:
$query= $this->db->get_where('navigation', 'linkname IS NOT NULL
AND parent IS NULL
AND type="main" //this doesn't work!!
AND ORDER BY sortnumber ASC');
Run Code Online (Sandbox Code Playgroud)
如何以合理的方式将type ="main"添加到此语句中?非常感谢!
我试图在控制器的索引函数中初始化数据,以便初始化的数据可以用在控制器的后续功能中.但问题是,当我尝试从其他功能访问数据时,数据未显示.所有这些只是为了遵循一种面向对象的模式.
这是我的代码.
class Dashboard extends CI_Controller
{
private $account_data; /*Declaration*/
private $profile_data;
function __construct() {
// code...
}
function index() /*Here I am initializing data*/
{
$this->load->model('db_model');
$this->account_data = $this->db_model->get_row();
$this->profile_data = $this->db_model->get_row();
$this->load->view('user/dashboard');
}
function function account_details()
{
print_r($this->account_data); // This displays nothing
}
/*other function...*/
}
Run Code Online (Sandbox Code Playgroud)
想法是获取一次数据并将其用于其他功能,如果再次更新数据则调用函数来初始化它.
但它没有成功.请帮我.还建议我是否遵循正确的方法.谢谢你的时间.
我在pyrocms中有一个模块,它被称为事件,因为由于已经存在的事件类,我无法将其称为事件
我想让localhost/events url引导到事件模块,所以我尝试在event/config/routes.php中设置一个路由
用这条线
$route['events/(:any)?'] = 'event/$1';
Run Code Online (Sandbox Code Playgroud)
但这不起作用 - 我做错了什么?
我已经开始尝试使用codeigniter和pdfs.我正在使用两者的最新版本.出于某种原因,我在尝试渲染pdfs时遇到此错误:
Warning: require_once(C:\Users\Manfred\Dropbox\Web\Alodu\application\helpers\dompdf/include/ci_exceptions.cls.php) [function.require-once]: failed to open stream: No such file or directory in C:\Users\Manfred\Dropbox\Web\Alodu\application\helpers\dompdf\dompdf_config.inc.php on line 208
Fatal error: require_once() [function.require]: Failed opening required 'C:\Users\Manfred\Dropbox\Web\Alodu\application\helpers\dompdf/include/ci_exceptions.cls.php' (include_path='.;C:\php\pear') in C:\Users\Manfred\Dropbox\Web\Alodu\application\helpers\dompdf\dompdf_config.inc.php on line 208
Run Code Online (Sandbox Code Playgroud)
使用的代码是:
function pdf()
{
$this->load->helper(array('dompdf', 'file'));
// page info here, db calls, etc.
/*
$data=array(
"$title"=>"Hello!",
"$test_questions"=>"1,2,3,4",
);
*/
$data['test_questions']= "hello";
$html = $this->load->view('pdf/test_ibdp', $data, true);
$filename="Test".$data['test_questions'];
pdf_create($html, $filename);
write_file('name', $data);
}
Run Code Online (Sandbox Code Playgroud)
帮助者:
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
function pdf_create($html, $filename, $stream=TRUE)
{
require_once("dompdf/dompdf_config.inc.php");
$dompdf …Run Code Online (Sandbox Code Playgroud) 我有以下数据库表.
id article_content article_views
1 content.. 48
Run Code Online (Sandbox Code Playgroud)
我试图article_views使用mysql查询增加列的值.
我知道我可以获取数字,然后添加+1然后更新值,但有没有更好的方法来做到这一点?
谢谢 :)
我的自定义功能不起作用.我正在检查数据库中是否存在传递的值,它返回错误消息.我做错了什么?
控制器功能
function sp_exists($str)
{
$this->user_model->sp_exists($str);
$this->form_validation->set_message('sp_exists', 'The %s field does not exists');
}
Run Code Online (Sandbox Code Playgroud)
模型功能
function sp_exists($str)
{
$this->db->where('member_id',$str);
$query = $this->db->get('user');
if ($query->num_rows() > 0)
{
return false;
}
else
{
return true;
}
}
Run Code Online (Sandbox Code Playgroud)
回调函数
$this->form_validation->set_rules('sponsor_id', 'Sponsor ID', 'trim|required|xss_clean|callback_sp_exists');
Run Code Online (Sandbox Code Playgroud) 使用CodeIgniter学习如何使用php和mysql.遇到那个错误.
我试图检查对我的数据库的登录尝试,它们存储在哪里.以下是我的登录模型中的相关功能:
public function verify_user($email, $password)
{
$q = $this
->db
->where('email_address', $email)
->where('password', $password)
->limit(1)
->get('users');
if ($q->num_rows > 0)
return $q->row();
}
add_login_attempt($email);
return false;
}
public function add_login_attempt($email)
{
$current_attempts = get_login_attempts($email);
if ($current_attempts > 2)
{
lock_account($email);
}
else
{
$updated_attempts = $current_attempts + 1;
$data = array('login_attempts' => $updated_attempts);
$this->db->where('email_address', $email);
$this->db->update('crm', $data);
}
}
function reset_login_attempts($email)
{
}
function lock_account($email)
{
}
public function get_login_attempts($email)
{
$this->db->select('login_attempts');
$this->db->from('crm');
$this->db->where('email_address', $email);
$login_attempts = $this->db->get();
return …Run Code Online (Sandbox Code Playgroud) codeigniter ×10
php ×5
mysql ×2
dompdf ×1
oop ×1
pyrocms ×1
routing ×1
session ×1
sql ×1
validation ×1