http://127.0.0.1/masterlinkci2/admin/cpages/pages
I get this error message:
A PHP Error was encountered
Severity: Notice
Message: Undefined property: Cpages::$gionda_date
Filename: controllers/Cpages.php
Line Number: 200
Line 200: $data['gionda_date'] = $this->gionda_date->g_date();
controllers/Cpages.php
public function pages() {
$data['pagessuccess'] = '';
$data['pages'] = $this->Mpages->call_pages();
$data['gionda_date'] = $this->gionda_date->g_date();
$this->load->view('pages', $data);
}
libraries/gionda_date.php
class Gionda_date {
private $CI;
public function __construct()
{
$this->CI = &get_instance();
}
public function g_date()
{
$datestring = 'Year: %Y Month: %m Day: %d - %h:%i %a';
return $datestring;
}
Can anyone help me fix the error messages?
Is you library loaded in your Cpages controller?
$this->gionda_date->g_date();
edited because of comment here is the most likely solution:
$this->load->library('gionda_date')
Related
I got an error trying to function edit
I got an error trying to function edit
to be honest I'm confused about placing the form validation library in codeigniter 4. can you guys help me?
edit_profile.php
public function edit_profile()
{
$data['title'] = 'Edit Profile';
// $users = new \Myth\Auth\Models\UserModel();
// $data['users'] = $users->findAll();
$this->form_validation->setRule('username', 'Username', 'required|trim');
if ($this->form_validation->run() == false) {
$this->builder->select('users.id as userid, username, fullname, user_image, email, name');
$this->builder->join('auth_groups_users', 'auth_groups_users.user_id = users.id');
$this->builder->join('auth_groups', 'auth_groups.id = auth_groups_users.group_id');
$this->query = $this->builder->get();
$data['users'] = $this->query->getResult();
}
return view('user/edit_profile');
}
}
I am using method post to create new data in xml file but The function c_element cannot be used in the function store
$DeTai = c_element('DeTai', $root);
This is my current code:
public function c_element($e_name, $parent)
{
global $xml;
$node = $xml->createElement($e_name);
$parent->appendChild($node);
return $node;
}
public function c_value($value, $parent)
{
global $xml;
$value = $xml->createTextNode($value);
$parent->appendChild($value);
return $value;
}
public function store(Request $request)
{
$xml = new DOMDocument("1.0","UTF-8");
$xml->load('../xml/QuanLyDoAnTotNghiep.xml');
if ($request->isMethod('post'))
{
$madt= $request->madt;
$noidungdetai = $request->noidungdetai;
$root=$xml->getElementsByTagName("QuanLyDoAnTotNghiep")->item(0);
$DeTai = c_element("DeTai", $root); //error in here
$s_madt = c_element('MaDT', $DeTai);
c_value("$madt", $s_madt);
$s_noidungdetai = c_element('NoiDungDeTai', $DeTai);
c_value("$noidungdetai", $s_noidungdetai);
$xml->formatOutput=true;
$xml->save('../xml/QuanLyDoAnTotNghiep.xml');
echo "Thêm mới thành công!!!";
}
}
use this keyword to call one method in different method of same class
$DeTai = $this->c_element('DeTai', $root);
to know more about it please visit this
Thanks..
An uncaught Exception was encountered
Type: Error
Message: Call to undefined method MY_Loader::_ci_object_to_array()
Filename: C:\xampp\htdocs\hhh\application\third_party\MX\Loader.php
Line Number: 300
Try this. Add it in the MY_Loader.
<?php (defined('BASEPATH')) OR exit('No direct script access allowed');
/* load the MX_Loader class */
require APPPATH."third_party/MX/Loader.php";
class MY_Loader extends MX_Loader
{
/** Load a module view **/
public function view($view, $vars = array(), $return = FALSE)
{
list($path, $_view) = Modules::find($view, $this->_module, 'views/');
if ($path != FALSE)
{
$this->_ci_view_paths = array($path => TRUE) + $this->_ci_view_paths;
$view = $_view;
}
return $this->_ci_load(array('_ci_view' => $view, '_ci_vars' => ((method_exists($this,'_ci_object_to_array')) ? $this->_ci_object_to_array($vars) : $this->_ci_prepare_view_vars($vars)), '_ci_return' => $return));
}
}
hello below is my model
<?php
class Orm_demo_model extends DataMapper{
var $table= 'orm_demo';
var $has_many=array('post_model');
var $validation =array(
'name'=>array(
'label'=>'Name',
'rules'=>array('required','trim'),
),
'description'=>array(
'label'=>'Description',
'rules'=>array('required','trim'),
)
);
}
//End Of Orm_demo .php model ..
And this is my controler
<?php
class OrmCtrl extends CI_Controller{
function __construct() {
parent::__construct();
}
function index(){
$data['title']='Add data';
$this->template->load('templates/template','ormDemoForm',$data);
}
function save(){
$obj = new Orm_demo_model();
$obj->name=$this->input->post('name');
$obj->description= $this->input->post('description');
if($obj->save()){
echo '<script>alert("Record Added..");</script>';
redirect('ormCtrl/','refresh');
}
else{
echo $obj->error->name;
echo $obj->error->description;
// echo $obj->error->string;
}
}
}
//end of ormCtrl.php file
now problem is that it can't show error message when validation failed...
it returns following message.
Unable to access an error message corresponding to your rule name: required.
Unable to access an error message corresponding to your rule name: required.
please tell me whats problem is there..?
I downloaded the EasyImage extension for Yii to crop images but whenever i want to init the image this fatal error comes up:
Fatal error: Call to undefined method Image::factory() in C:\Users\Daniel\Documents\GitHub\askengine\protected\extensions\yii-easyimage\EasyImage.php on line 41
Cant figure out why.
My Controller:
Yii::import('ext.yii-easyimage.EasyImage');
$image = new EasyImage("avatar/".$fileName);
$image->crop($_POST['w'], $_POST['h'], $_POST['x1'], $_POST['y1']);
$image->save();
The EasyImage class _construct():
public function __construct($file = null, $driver = null)
{
if ($file) {
return $this->_image = Image::factory($this->detectPath($file), $driver ? $driver : $this->driver);
}
}
And the Image.php :
public static function factory($file, $driver = NULL)
{
if ($driver === NULL) {
// Use the default driver
$driver = Image::$default_driver;
}
// Set the class name
$class = 'Image_' . $driver;
return new $class($file);
}
I tried to use directly the Image.php but it ended with failure:
Fatal error: Call to undefined method Image::factory() in C:\Users\Daniel\Documents\GitHub\askengine\protected\controllers\ImageController.php on line 60