A PHP Error was encountered - Code Igniter

a php error was encountered severity: warning meaning
backtrace error in codeigniter
undefined property codeigniter model
filename core model php line number 73
what is a php error
a php error was encountered chrome
an error was encountered
function _error_handler

I'm trying to fetch data from my database to a data table with table headers "Total No. of Students | Male | Female"

This is the error it showed

Severity: Notice

Message: Undefined property: stdClass::$totalcount

Filename: pages/studentgender.php

Line Number: 20

Backtrace:

File: C:\xampp\htdocs\libsystem\application\views\pages\studentgender.php Line: 20 Function: _error_handler

File: C:\xampp\htdocs\libsystem\application\controllers\Students.php Line: 30 Function: view

This is my model

public function studentCountGender(){
    $this->db->select('studgender, COUNT(*) as totalcount, COUNT(   case when studgender = "Male" then 1 else 0 end)
                        AS malecount, COUNT(    case when studgender = "Female" then 1 else 0 end) AS femalecount');
    $this->db->from('student');
    $query = $this->db->get();
    return $query->result();
}
}

This is my controller

 public function studentList(){

    $this->load->model('student_model');
    $data['result'] = $this->student_model->studentCountGender();
    $this->load->view('templates/header');
    $this->load->view('templates/sidebar');
    $this->load->view('pages/studentgender', $data);
}

This is my view

    <thead>
        <tr>
          <th>Total No. of Students</th>
            <th>Total Number of Males</th>
            <th>Total Number of Females</th>
        </tr>
    </thead>
    <tbody> 
    <?php
    foreach($sample as $item){
      echo '<tr>
        <td>'.$item->totalcount.'</td>
        <td>'.$item->malecount.'</td>
        <td>'.$item->femalecount.'</td>
      </tr>
    </tbody>
    ';}?>
</table>
            </div>
        </div>
    </div>
</div>

Can someone help me how to parse it and it will not show the error? I've been trying to debug this for 2 hours and it's making me insane thanks alot!!!

Please try the below code hope this help you. may you don't have the result or pass the $data in incorrect view please check accordingly.

<?php 
    if(isset($result)&& !empty($result)){
            foreach($result as $item){
              echo "<tr>
                 <td>".$item->totalcount."</td>
                  <td>".$item->malecount;"</td>
                 <td>".$item->femalecount."</td>
                </tr>";
            }
    }
        ?>

A PHP Error was encountered, Please Help me to solve the errors. Thank You. Pankaj Kumar. A PHP Error was encountered. Severity: Notice Message: Undefined variable:  the publisher could not be verified. are you sure you want to run this software kata ini muncul ketika habis instal idm yang di crak kan m

Try this code once.

<?php
    foreach($result as $item){
      echo "<tr>
         <td>{$item->totalcount}</td>
          <td>{$item->malecount}</td>
         <td>{$item->femalecount}</td>
        </tr>";
    }
?>

Codeigniter model class through this error - PHP, A PHP Error was encountered Severity: Notice Message: Undefined property: FirstController::$db Filename: core/Model.php Line Number: 77  CodeIgniter provides an easy error handling mechanism. You would like the messages to be displayed, when the application is in developing mode rather than in production mode as the error messages can be solved easily at the developing stage. The environment of your application can be changed, by changing the line given below from index.php file.

You are passing $data['result'] to the view , Then how do you get result in $sample as $item in foreach. Please check again.

Code igniter view page throw this error - PHP, A PHP Error was encountered Severity: Notice Message: Use of undefined constant user_array - assumed 'user_array' Filename:  Sekedar Tips bagi yang merasa kesulitan dengan query insert multiple data dengan checkbox dan PHP , Sebagai contoh kita buat dulu datab

Try this, will work for you.

Your controller:

public function __construct()
{
  parent::__construct();
  $this->load->model('student_model');
}

public function studentList(){
    $data = [];
    $data['result'] = $this->student_model->studentCountGender();
    $this->load->view('templates/header');
    $this->load->view('templates/sidebar');
    $this->load->view('pages/studentgender', $data);
}

Your model:

<?
public function studentCountGender(){
    $this->db->select('studgender, COUNT(*) as totalcount, COUNT(   case when studgender = "Male" then 1 else 0 end)
                        AS malecount, COUNT(    case when studgender = "Female" then 1 else 0 end) AS femalecount');
    $this->db->from('student');
    $query = $this->db->get();
    return $query->result();
}

Your view:

foreach($result as $item){
      echo '<tr>
        <td>'.$item->totalcount.'</td>
        <td>'.$item->malecount.'</td>
        <td>'.$item->femalecount.'</td>
      </tr>
    </tbody>
    }

Greetings!

codeigniter Deprecated error and A PHP Error was encountered, Deprecated: Assigning the return value of new by reference is deprecated in D:\​xampp\htdocs\hes\system\codeigniter\Common.php on line 123 Sebaiknya menggunakan versi PHP terbaru dan versi CodeIgniter yang terbaru juga. Namun kalau ingin tetap menggunakan versi CodeIgniter yang lama, maka akan sedikit repot dengan cara seperti di atas. Facebook Comments

In your view use $result rather than $sample hope this will work

[SOLVED] Error when calling model after extending the controller class, A PHP Error was encountered. Severity: CodeIgniter.php:236 4 0.0320 1) You need to specify your CodeIgniter Version CI 1.7.X or CI 2.0 The tutorial gives 404 errors everywhere :(¶ You can’t follow the tutorial using PHP’s built-in web server. It doesn’t process the .htaccess file needed to route requests properly. The solution: use Apache to serve your site, or else the built-in CodeIgniter equivalent, php spark serve from your project root.

CodeIgniter - Error Handling, CodeIgniter - Error Handling - Many times, while using application, we come application can be changed, by changing the line given below from index.php show_error($message, $status_code, $heading = 'An Error Was Encountered'). The idea with CSRF is exactly for you not to resubmit the same form twice. The alternative solution would be to do a redirect (to the same controller/function if you want to return tot the form after submitted some data) after you saved the form data.

Solusi Error Pada core/common.php di CodeIgniter, Silahkan mencoba jika dapat error. Solusi Error Pada core/common.php di CodeIgniter. Created 7 April A PHP Error was encountered. CodeIgniter Rocks. CodeIgniter is a powerful PHP framework with a very small footprint, built for developers who need a simple and elegant toolkit to create full-featured web applications.

CodeIgniter-Tutorial/error_php.php at master · mikedfunk , CodeIgniter-Tutorial/application/errors/error_php.php / Jump to. Code definitions <h4>A PHP Error was encountered</h4>. <p>Severity: <?php echo $severity  SOURCE CODE APLIKASI BUTIK TOKO ONLINE DENGAN PHP MYSQLI. Follow us On Facebook. DB - Dunia Blogsqu

Comments
  • From where did you bring $sample?
  • Possible duplicate of Reference - What does this error mean in PHP?
  • can you paste query result here ?
  • replace $sample with $data['result'] . I hope it will work.
  • just do var_dump($data), You will get an idea
  • changed it to $result but it showed Message: Undefined variable: result
  • changed it to $result but it showed Message: Undefined variable: result