我是CodeIgniter的新手.这是我的代码:
class User_model extends CI_Model {
function validate_user() {
$this->db->select('*');
$this->db->from('user');
$this->db->where('username', $this->input->post('username'));
$this->db->where('password', md5($this->input->post('password')));
$validate_user = $this->db->get();
if($validate_user->num_rows == 1) {
return TRUE;
}
}
}
Run Code Online (Sandbox Code Playgroud)
我在我的模型文件中收到此错误:
Call to a member function select() on a non-object
Run Code Online (Sandbox Code Playgroud)
目前我正在使用CodeIgniter 2.1.0版.请帮我!
关于如何在每个第3个角色中添加破折号我遇到了问题.例如,我想要
ABCDEF turn into ABC-DEF
Run Code Online (Sandbox Code Playgroud)
我有这个代码:
$string = 'ABCDEF';
echo substr_replace(chunk_split($string,3),'-','3','2');
// the output is ABC-DEF
Run Code Online (Sandbox Code Playgroud)
但是,如果我向$ string变量添加更多字符,则此代码不起作用ABCDEFGHI
.如果我使用上面的代码,输出将是:
ABC-DEF GHI
Run Code Online (Sandbox Code Playgroud) 我不知道如何解决这个问题.使用Apache Web服务器将此项目部署到生产服务器时发生问题.我尝试在Apache Web服务器上更改DocumentRoot.(CakePHP文档)但仍然没有运气.
但是如果我使用./cake server命令(http:// localhost:8765 /)在开发服务器下运行项目,那么似乎没问题.我可以创建,检索,更新,删除.没有数据库错误
请帮我.
如何使用SQL语句获取前3个月的数据?例如,如果当前日期是01/01/2012,那么如何获取2011年12月,11月,10月的数据?
请有人指导我.
我有重置用户密码的类.但代码总是给我一个错误:
Fatal error: Call to undefined function newRandomPwd() in
C:\AppServ\www\phonebook\application\controllers\reset.php
on line 32
Run Code Online (Sandbox Code Playgroud)
这是我的代码:
class Reset extends CI_Controller{
function index(){
$this->load->view('reset_password');
}
function newRandomPwd(){
$length = 6;
$characters = 'ABCDEF12345GHIJK6789LMN$%@#&';
$string = '';
for ($p = 0; $p < $length; $p++) {
$string .= $characters[mt_rand(0, strlen($characters))];
}
return $string;
}
function resetPwd(){
$newPwd = newRandomPwd(); //line 32, newRandomPwd()
//is undefined
$this->load->library('form_validation');
$this->load->model('user_model');
$getUser = $this->user_model->getUserLogin();
if($getUser)
{
$this->user_model->resetPassword($newPwd);
return TRUE;
} else {
if($this->form_validation->run()==FALSE)
{
$this->form_validation->set_message('','invalid username');
$this->index();
return FALSE; …
Run Code Online (Sandbox Code Playgroud) Array (
[0] => myemail@domain.com
[1] => mysecondemail@domain.com
[2] => invalidEmail.com
)
Run Code Online (Sandbox Code Playgroud)
请注意,第三个数组值是无效的电子邮件格式.如何使用/创建功能将其删除?implode("," the valid email)
在使用该mail()
功能发送电子邮件之前,我需要有效的电子邮件.
我在 MySQL 事件上遇到了问题。我希望这个活动在每年的第一天举行。目前我的活动将每月举行。这是我的活动脚本。
DELIMITER $$
CREATE EVENT create_ledger
ON SCHEDULE EVERY '1' MONTH
STARTS '2016-05-20 11:33:01'
DO
BEGIN
insert into ledger SET ledger_year= YEAR(CURDATE());
END$$
DELIMITER ;
Run Code Online (Sandbox Code Playgroud)
希望有人可以帮忙。全面质量管理
我试图通过在PHP中使用此技术来更改值,但它不起作用!不幸的是,我也不知道这种技术的名称.因此限制我在谷歌搜索解决方案.
echo $session_slct->f("theMonth") == '01' ? "January" ||
$session_slct->f("theMonth") == '02' ? "February" ||
$session_slct->f("theMonth") == '03' ? "March" ||
$session_slct->f("theMonth") == '04' ? "April" ||
$session_slct->f("theMonth") == '05' ? "May" ||
$session_slct->f("theMonth") == '06' ? "June" ||
$session_slct->f("theMonth") == '07' ? "July" ||
$session_slct->f("theMonth") == '08' ? "August" ||
$session_slct->f("theMonth") == '09' ? "September" ||
$session_slct->f("theMonth") == '10' ? "October" ||
$session_slct->f("theMonth") == '11' ? "November" ||
$session_slct->f("theMonth") == '12' ? "December" : "Invalid Month!";
Run Code Online (Sandbox Code Playgroud) php ×6
codeigniter ×2
mysql ×2
arrays ×1
cakephp ×1
cakephp-3.0 ×1
events ×1
function ×1
if-statement ×1
replace ×1
reset ×1
short ×1
sql ×1
string ×1
substr ×1
validation ×1