Welcome Guest, Not a member yet? Register   Sign In
Query Error
#1

[eluser]Atrhick[/eluser]

Guys I have a quick question can you please tell me what I did wrong here.

MODEL:
Code:
class Videoswatchedchart_model extends CI_Model{

  function Videoswatchedchart_model(){

   parent::__construct();

  }

function month_daily_watched_videos()

    {

    $query_str = " SELECT videos_watched, todaysdate "
     ." FROM Video_views "
     ." WHERE MONTH(todaysdate) = MONTH(NOW()) ";

  $result = $this->db->query($query_str);

  $month_daily_watched= array();

  if($result->num_rows() > 0)

  {

  $month_daily_watched = $result->row();

  $month_daily_watched = $month_daily_watched->month_daily_watched;

  }

   return $month_daily_watched;

}


}
CONTROLER:
Code:
class Videoswatchedchart extends CI_Controller{



function Videoswatchedchart(){

  

  parent::__construct();

  $this->view_data['base_url'] = base_url();

}



function index(){

  

  $this->videoswatchedchart_view();

}



function videoswatchedchart_view(){

  

  if ($this->session->userdata('logged_in') !== FALSE)

   {

    $month_daily_watched['month_daily_watched'] = $this->Videoswatchedchart_model->month_daily_watched_videos();
  

    $this->view_data['month_daily_watched'] = $this->Videoswatchedchart_model->month_daily_watched_videos();


    $this->load->view('videos_watched_view', $this->view_data);

    }

  else

   {

     $hackerror['hackerror'] = "Please Login Again!";

     $this->load->view('login_view', $hackerror);

   }



}



}

ERROR:
Code:
A PHP Error was encountered

Severity: Notice

Message: Undefined property: stdClass::$month_daily_watched

Filename: models/videoswatchedchart_model.php

Line Number: 31
A PHP Error was encountered

Severity: Notice

Message: Undefined property: stdClass::$month_daily_watched

Filename: models/videoswatchedchart_model.php

Line Number: 31
#2

[eluser]Kamarg[/eluser]
In your model you have
Code:
$month_daily_watched = $month_daily_watched->month_daily_watched;
But you don't ever select a field in your query called month_daily_watched. You can only use the fields "videos_watched" and "todaysdate" since that's all you select in your query.
#3

[eluser]Atrhick[/eluser]
[quote author="Kamarg" date="1332521930"]In your model you have
Code:
$month_daily_watched = $month_daily_watched->month_daily_watched;
But you don't ever select a field in your query called month_daily_watched. You can only use the fields "videos_watched" and "todaysdate" since that's all you select in your query.[/quote]

wow yea that makes perfect sense..... i need to take a break i have been coding too long how.




Theme © iAndrew 2016 - Forum software by © MyBB