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);
Related
I've moved from PHP5 to PHP7.
The following code no longer works.
<?php
class sandbox {
function doit() {
$method = array('name' => 'testresponse');
return $this->$method['name']();
}
function testresponse(){
return "Hi!";
}
}
$h = new sandbox();
echo "Hello, " . $h->doit();
I'm wondering what is the new syntax for this?
Here are the PHP errors I'm getting
A PHP Error was encountered Severity: Notice
Severity: Notice
Message: Array to string conversion
Filename: front/sandbox.php
Line Number: 20
And
Fatal error: Uncaught Error: Function name must be a string in /var/www/application/controller/sandbox.php:20 Stack trace: #0
Change this
return $this->$method['name']();
to this
return $this->{$method['name']}();
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
api layer (move_shopping_list.php):
if (!isset($_GET['i_sign_in_token'])){
die(json_encode('Must pass in the i_sign_in_token into the url'));
}
if (!isset($_GET['itm_cd'])){
die(json_encode('Must pass in itm_cd into the URL'));
}
if (!isset($_GET['list_id_old']) || !isset($_GET['list_id_new'])){
die(json_encode('Must pass in the list_id_old or new value into the URL'));
}
$list = new ShoppingListItem($_GET['i_sign_in_token'], $_GET['itm_cd'], $_GET['list_id_old'], $_GET['list_id_new']);
$moveItems = $item->move_between_lists($token, $_GET['itm_cd'], $_GET['list_id_old'], $_GET['list_id_new']);
echo json_encode($moveItems);
Here is my move between lists method inside of my ShoppingListItem class:
public function move_between_lists($shopper, $new_list_id) {
global $pd, $db;
// todo: don't forget to update $this->ShoppingList
$vars = array();
$vars[] = array('i_sign_in_token', $shopper);
$vars[] = array('itm_cd', $this->ITM_CD);
$vars[] = array('list_id_old', $this->SHOPPING_LIST_ID);
$vars[] = array('list_id_new', $new_list_id);
$rows = $db->get_function_as_proc('custom.japi_shopping_list.Move_Bewteen_Lists(:i_sign_in_token, :itm_cd, :list_id_old, :list_id_new)', $vars);
if ($rows == 'Y') {
// Must have worked or it would have returned.
$this->SHOPPING_LIST_ID = $new_list_id;
return true;
} else {
return false;
}
}
I keep getting these errors and i have no idea why.. any help would be greatly appreciated.
Notice: Undefined index: i_sign_in_token in /var/www/api/move_shopping_list.php on line 3 Notice: Undefined index: itm_cd in /var/www/api/move_shopping_list.php on line 7 Notice: Undefined index: list_id_old in /var/www/api/move_shopping_list.php on line 11 Notice: Undefined index: list_id_new in /var/www/api/move_shopping_list.php on line 15 Notice: Undefined index: i_sign_in_token in /var/www/api/move_shopping_list.php on line 19 Notice: Undefined index: itm_cd in /var/www/api/move_shopping_list.php on line 19 Notice: Undefined index: list_id_old in /var/www/api/move_shopping_list.php on line 19 Notice: Undefined index: list_id_new in /var/www/api/move_shopping_list.php on line 19 Notice: Undefined variable: item in /var/www/api/move_shopping_list.php on line 20 Fatal error: Call to a member function move_between_lists() on a non-object in /var/www/api/move_shopping_list.php on line 20
If the array key in $_GET is not set, you are explicitly checking whether or not this nonexistant key is also not an empty string. The logic is wrong, you must not use && (and) but || (or).
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);
I am getting the following error in the following code:
Class primeField implements field {
private $intmodulus = '';
public function generator(){
return ;
}
public function modulus(){
return $this->$intmodulus;
}
public function __construct($modulus , $base=0) {
if (is_resource($modulus) && get_resource_type($modulus) == "GMP integer"){
$this->$intmodulus = $modulus;
} else{
$this->$intmodulus = gmp_init($modulus , $base); \\line 70
}
}
}
$a = new primeField(11);
$a->modulus();
Notice: Undefined variable: intmodulus in /Users/admin/PHP ECC/finitefield.php on line 70
Fatal error: Cannot access empty property in /Users/admin/PHP ECC/finitefield.php on line 70
Why
The syntax is
$this->intmodulus
not $this->$intmodulus.
You get an error saying "cannot access empty property" because $intmodulus is undefined and hence accessing it gives NULL. The NULL gets converted into an empty string when you attempt to use it as a property name.
If the value of $intmodulus was the name of a valid property (e.g. if $intmodulus == "intmodulus"), you would be accessing the property with that name.
$this->$intmodulus should be $this->intmodulus
See the PHP documentation for Variable variables for info on what is happening.