A PHP Error was encountered
Severity: Error
Message: Call to undefined method Post::where()
Filename: models/post.php
Line Number: 23
This is my edit controller
function editpost($postID){
$data['success']=0;
if($_POST){
$data_post=array(
'title'=>$_POST['title'],
'post'=>$_POST['post'],
'active'=>1
);
$this->post->update_post($postID,$data_post);
$data['success']=1;
}
$data['post']=$this->post->get_post($postID);
$this->load->view('edit_post',$data);
}
this is my update model
function update_post($postID,$data){
$this->where('postID',$postID);
$this->db->update('posts',$data);
}
I changed the data_post - data same error
Where is my error?
put $this->db->where('postID',$postID);
$this->db->update('posts',$data) in your model code
Follow bellow code:
function update_post($postID,$data){
$this->db->where('postID',$postID);
$this->db->update('posts',$data);
}
Please change your update_post function code from $this->where('postID',$postID);
to $this->db->where('postID',$postID);. You missing ->db before ->where condition in your model page.
Thanks
Related
This question already has answers here:
How to load a controller from another controller in codeigniter?
(10 answers)
Closed 4 years ago.
I have the Login_controller:
if ($query->num_rows() == 1){
$usuario = $query->row();
$this->load->library('../controllers/Dashboard_controller');
}
And I have the Dashboard_Controller:
public function index(){
$this->load->view("dashboard/Dashboard_view");
}
}
But, I got a message error:
A PHP Error was encountered
Severity: Notice
Message: Undefined property: Dashboard_controller::$load
Filename: libraries/Form_validation.php
Line Number: 147
Backtrace:
File: C:\xampp\htdocs\local\acjum1\application\controllers\Login_controller.php
Line: 34
Function: library
File: C:\xampp\htdocs\local\acjum1\index.php
Line: 315
Function: require_once
An uncaught Exception was encountered
Type: Error
Message: Call to a member function helper() on null
Filename: C:\xampp\htdocs\local\acjum1\system\libraries\Form_validation.php
Line Number: 147
Backtrace:
File: C:\xampp\htdocs\local\acjum1\application\controllers\Login_controller.php
Line: 34
Function: library
File: C:\xampp\htdocs\local\acjum1\index.php
Line: 315
Function: require_once
What am I doing wrong?
Try this one
redirect('/dashboard/index');
This question was asked before.
Basically you are calling the controller but not the index function.
Please refer to : How to load a controller from another controller in codeigniter?
I try to used to an old customized module in my Prestashop that runs with php 7.0.
I got an error and no idea...
Fatal error: Uncaught Error: Call to undefined method Product::getFrontFeaturesHiddenByNameStatic()
And here is the line of code.
$feature = Product::getFrontFeaturesHiddenByNameStatic((int)($params['cookie']->id_lang), $product['id_product'],'_Descriptif accueil');
And that function is defined in "override" folder.
public static function getFrontFeaturesHiddenByNameStatic($id_lang, $id_product, $featureName) {
self::getFrontFeaturesStatic($id_lang, $id_product);
if( isset(self::$_frontFeaturesCacheHidden[$id_product.'-'.$id_lang]) )
foreach(self::$_frontFeaturesCacheHidden[$id_product.'-'.$id_lang] as $feature) {
if( $featureName == $feature["name"] )
return $feature;
}
return null; // nothing has been found
}
Thanks in advance !
I think I found the solution.
Actually the override definition was not in the right folder.
It was in override/classes and failed, while set in modules/mymodule/override/classes, it seems to work fine...
Thank for your help!
I'm trying to join my table and it's working but I don't know why I got the following error messages.
A PHP Error was encountered
Severity: Notice
Message: Undefined variable: get
Filename: views/tambah_wali.php
Line Number: 13
Fatal error: Call to a member function result() on a non-object in C:\xampp\htdocs\ujikom_sekolah\application\views\tambah_wali.php on line 13
This is my controller:
public function tambah_wali($kode){
$data['get']=$this->madm->join_wali_siswa($kode);
$this->load->view('tambah_wali');
}
This is my model:
public function join_wali_siswa($kode) {
$this->db->select('wali_murid.nisn');
$this->db->from('siswa');
$this->db->join('wali_murid','siswa.nisn=wali_murid.nisn','right');
$this->db->where('siswa.nisn',$kode);
$query=$ambildata=$this->db->get();
if($ambildata->num_rows > 0)
return $query;
else
return null;
}
This is line 13 on my view:
<?php foreach($get->result() as $row): ?>
Load your $data['get'] in your view seems to be missing when have a $data variable must add it to view like below.
$data['get'] = $this->madm->join_wali_siswa($kode);
$this->load->view('tambah_wali', $data);
public function adduser()
{
$this->load->model('User', 'user');
$this->user->adduser();
$data = array('message' => 'Thanks for signing up');
$this->load->view('register', $data);
}
This is my function and it executes perfectly and gives a message of thanks to the register view page. But when I am loading the register view page initially, it gives me an error.
A PHP Error was encountered
Severity: Notice
Message: Undefined variable: message
Filename: views/register.php
Line Number: 15
if anyone can help where it is going wrong.
Regard to the comment section mentioned workaround is
<?php echo ((isset($message)) ? $message : '');?>
Please see ternary operator.
For some reason i cant get my model to work.. never had this problem before.
function overview($userid)
{
// Load needed model
$this->load->model('budget_model');
$data['month_budget'] = $this->budget_model->get_monthly_budget($userid);
if(isset($_POST['submit']))
{
foreach($_POST as $key => $value)
{
if(is_numeric($key))
{
$this->buget_model->update_buget($key,$value);
echo "DONE";
}
}
echo "<pre>";
print_r($_POST);
echo "</pre>";
}
$data['main'] = 'super_admin/budget_edit_overview_view';
$this->load->view('default/main_view',$data);
}
The model works fine with "$this->budget_model->get_monthly_budget($userid);" but i keep getting thir error,
A PHP Error was encountered
Severity: Notice
Message: Undefined property: Admin::$buget_model
Filename: controllers/admin.php
Line Number: 166
Fatal error: Call to a member function update_buget() on a non-object
in /Applications/MAMP/htdocs/therace/application/controllers/admin.php
on line 166
The model method,
function update_buget($id,$budget)
{
$this->db->where('id', $id);
// Update the month budget
$data = array(
'month_goal' => $budget
);
$this->db->update('budget_month', $data);
return true;
}
Read the error message carefully:
Message: Undefined property: Admin::$buget_model
Did you make a typo and actually mean $budget_model?
edit: There seems to be a lot of budget vs. buget in your code. I suggest a spellchecker.
You have made a typing error in line 166.
It is $this->budget_model->update_buget($key,$value);
not $this->buget_model->update_buget($key,$value);