mysql - How to fix this message ?Severity: Notice --> Undefined property: stdClass:: -
enter image description herei trying display table mysql db using codeigniter , angularjs doing wrong? view: list_show_data.php
<?php defined('basepath') or exit('no direct script access allowed'); ?><!doctype html> <html ng-app="app"> <head> <meta charset="utf-8"> <title>list show data</title> <link rel="stylesheet" src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> </head> <body> <div ng-controller="decontroller"> <table class="table table-bordered table-striped table-hover"> <thead> <tr> <th>first name</th> <th>last name</th> <th>email</th> <th>role</th> <th>privileges</th> <th>user name</th> </tr> </thead> <tbody> <tr ng-repeat="n in list_data"> <td>{{n.first name}}</td> <td>{{n.last name}}</td> <td>{{n.email}}</td> <td>{{n.role}}</td> <td>{{n.privileges}}</td> <td>{{n.user name}}</td> </tr> </tbody> </table> </div> <script type="text/javascript" href="/public/js/angular.js"> </script> <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.6/angular.min.js"> </script> <script type="text/javascript"> var app = angular.module('app',[]); app.controller('decontroller', function($scope,$http){ $scope.list_data=[]; $http.get("ajax_load_data").success(function(result){ $scope.list_data=result; }); }); </script> </body> </html>
this controller:maintest.php
<?php defined('basepath') or exit('no direct script access allowed'); class maintest extends ci_controller { /** * index page controller. * * maps following url * http://example.com/index.php/welcome * - or - * http://example.com/index.php/welcome/index * - or - * since controller set default controller in * config/routes.php, it's displayed @ http://example.com/ * * other public methods not prefixed underscore * map /index.php/welcome/<method_name> * @see https://codeigniter.com/user_guide/general/urls.html */ public function list_show_data() { $this->load->helper('url'); $this->load->view('list_show_data'); } public function ajax_load_data() { $this->load->helper('url'); $res = $this->db->get('stlc_users')->result(); $data_arr = array(); $i=0; foreach($res $r) { $data_arr[$i]['first name'] = $r->first ; $data_arr[$i]['last name'] = $r->last ; $data_arr[$i]['email'] = $r->email; $data_arr[$i]['role'] = $r->role; $data_arr[$i]['privileges'] = $r->privileges; $data_arr[$i]['user name'] = $r->user ; $i++; } echo json_encode($data_arr); }
}
this error i'm getting:
severity: notice --> undefined property: stdclass::$first c:\xampp\htdocs\stlc\application\controllers\maintest.php 38 error - 2016-09-22 16:31:19 --> severity: notice --> undefined property: stdclass::$last c:\xampp\htdocs\stlc\application\controllers\maintest.php 39 error - 2016-09-22 16:31:19 --> severity: notice --> undefined property: stdclass::$user c:\xampp\htdocs\stlc\application\controllers\maintest.php 43
this error message means $r
object, represents row db table stlc_users
, not have these 2 properties: last
, user
. reason there no columns these names in db table.
Comments
Post a Comment