Yii Framework Forum: Trying To Get Property Of Non-Object - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Trying To Get Property Of Non-Object Trying to get property of non-object

#1 User is offline   ahmad albab 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 39
  • Joined: 07-January 14

Posted 08 February 2014 - 09:29 PM

hi guys...

may i know what does "Trying to get property of non-object" mean?
how and where can i look for the error?

thank you...:)
0

#2 User is offline   ORey 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,701
  • Joined: 20-April 09
  • Location:Moscow, Russia

Posted 08 February 2014 - 10:45 PM

This means that you're trying to access property of something, that is not an object.
For example, if you do something like this

$model = MyModel::model()->findByPk('non_existent_primary_key');


the $model will be null, so if you do

echo $model->id;


you'll get this error.
God is real unless declared as integer
0

#3 User is offline   ahmad albab 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 39
  • Joined: 07-January 14

Posted 08 February 2014 - 10:52 PM

View PostORey, on 08 February 2014 - 10:45 PM, said:

This means that you're trying to access property of something, that is not an object.
For example, if you do something like this

$model = MyModel::model()->findByPk('non_existent_primary_key');


the $model will be null, so if you do

echo $model->id;


you'll get this error.


hi ORey...
thanks for your explaination....:)
but can i show you mine?? i mean,,,my error...
i don't know how i suppose to find my "none property object"...
0

#4 User is offline   ORey 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,701
  • Joined: 20-April 09
  • Location:Moscow, Russia

Posted 08 February 2014 - 10:55 PM

sure, paste it right here.
God is real unless declared as integer
0

#5 User is offline   ahmad albab 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 39
  • Joined: 07-January 14

Posted 08 February 2014 - 11:13 PM

View PostORey, on 08 February 2014 - 10:55 PM, said:

sure, paste it right here.




thank you oRey..:D

Quote


PHP notice

Trying to get property of non-object

C:\BitNami\wappstack-5.4.22-0\apache2\htdocs\yii\framework\base\CComponent.php(612) : eval()'d code(1)
Stack Trace
#0
+
C:\BitNami\wappstack-5.4.22-0\apache2\htdocs\yii\framework\base\CComponent.php(612): eval()
#1
+
C:\BitNami\wappstack-5.4.22-0\apache2\htdocs\yii\framework\zii\widgets\grid\CDataColumn.php(137): CComponent->evaluateExpression("$data->neg->neg_lawat", array("data" => Permohonan, "row" => 4))
#2
+
C:\BitNami\wappstack-5.4.22-0\apache2\htdocs\yii\framework\zii\widgets\grid\CGridColumn.php(151): CDataColumn->renderDataCellContent(4, Permohonan)
#3
+
C:\BitNami\wappstack-5.4.22-0\apache2\htdocs\yii\framework\zii\widgets\grid\CGridView.php(616): CGridColumn->renderDataCell(4)
#4
+
C:\BitNami\wappstack-5.4.22-0\apache2\htdocs\yii\framework\zii\widgets\grid\CGridView.php(572): CGridView->renderTableRow(4)
#5
+
C:\BitNami\wappstack-5.4.22-0\apache2\htdocs\yii\framework\zii\widgets\grid\CGridView.php(482): CGridView->renderTableBody()
#6
+
C:\BitNami\wappstack-5.4.22-0\apache2\htdocs\yii\framework\zii\widgets\CBaseListView.php(167): CGridView->renderItems()
#7
unknown(0): CBaseListView->renderSection(array("{items}", "items"))
#8
+
C:\BitNami\wappstack-5.4.22-0\apache2\htdocs\yii\framework\zii\widgets\CBaseListView.php(150): preg_replace_callback("/{(\w+)}/", array(CGridView, "renderSection"), "{summary} {items} {pager}")
#9
+
C:\BitNami\wappstack-5.4.22-0\apache2\htdocs\yii\framework\zii\widgets\CBaseListView.php(135): CBaseListView->renderContent()
#10
+
C:\BitNami\wappstack-5.4.22-0\apache2\htdocs\yii\framework\web\CBaseController.php(173): CBaseListView->run()
#11

C:\BitNami\wappstack-5.4.22-0\apache2\htdocs\luar_negara\protected\views\permohonan\senaraiPermohonan.php(80): CBaseController->widget("zii.widgets.grid.CGridView", array("id" => "permohonan-grid", "dataProvider" => CActiveDataProvider, "columns" => array(array("header" => "Nama Pegawai", "value" => "$data->peg_ic"), array("header" => "Negara yang Dilawati", "value" => "$data->neg->neg_lawat"), array("header" => "Tarikh Mula Lawatan", "value" => "$data->moh_cutimula"), array("header" => "Tarikh Tamat Lawatan", "value" => "$data->moh_cutitamat"), ...)))

75 */
76 array(
77 'class'=>'CButtonColumn',
78 ),
79 ),
80 )); ?>

#12
+
C:\BitNami\wappstack-5.4.22-0\apache2\htdocs\yii\framework\web\CBaseController.php(126): require("C:\BitNami\wappstack-5.4.22-0\apache2\htdocs\luar_negara\protect...")
#13
+
C:\BitNami\wappstack-5.4.22-0\apache2\htdocs\yii\framework\web\CBaseController.php(95): CBaseController->renderInternal("C:\BitNami\wappstack-5.4.22-0\apache2\htdocs\luar_negara\protect...", array("model" => Permohonan), true)
#14
+
C:\BitNami\wappstack-5.4.22-0\apache2\htdocs\yii\framework\web\CController.php(869): CBaseController->renderFile("C:\BitNami\wappstack-5.4.22-0\apache2\htdocs\luar_negara\protect...", array("model" => Permohonan), true)
#15

C:\BitNami\wappstack-5.4.22-0\apache2\htdocs\luar_negara\protected\components\XController.php(14): CController->renderPartial("senaraiPermohonan", array("model" => Permohonan), true)

09
10 /* this class for support problem when using ajax renderpartial */
11 public function renderPartialX($view, $data = null, $return = false) {
12 $mainClientScript = Yii::app()->clientScript;
13 Yii::app()->setComponent('clientScript', new ZClientScript);
14 $output = $this->renderPartial($view, $data, true);
15 $output.=Yii::app()->clientScript->renderOnRequest();
16 Yii::app()->setComponent('clientScript', $mainClientScript);
17
18 if ($return)
19 return $output;

#16

C:\BitNami\wappstack-5.4.22-0\apache2\htdocs\luar_negara\protected\controllers\PermohonanController.php(250): XController->renderPartialX("senaraiPermohonan", array("model" => Permohonan))

245 }
246
247 $this->renderPartialX('senaraiPermohonan',array(
248 'model'=>$model,
249
250 ));
251 }
252
253 public function actionIndex()
254 {
255 $dataProvider=new CActiveDataProvider('Permohonan');

#17
+
C:\BitNami\wappstack-5.4.22-0\apache2\htdocs\yii\framework\web\actions\CInlineAction.php(49): PermohonanController->actionSenaraiPermohonan()
#18
+
C:\BitNami\wappstack-5.4.22-0\apache2\htdocs\yii\framework\web\CController.php(308): CInlineAction->runWithParams(array("r" => "permohonan/senaraiPermohonan"))
#19
+
C:\BitNami\wappstack-5.4.22-0\apache2\htdocs\yii\framework\web\filters\CFilterChain.php(133): CController->runAction(CInlineAction)
#20
+
C:\BitNami\wappstack-5.4.22-0\apache2\htdocs\yii\framework\web\filters\CFilter.php(40): CFilterChain->run()
#21
+
C:\BitNami\wappstack-5.4.22-0\apache2\htdocs\yii\framework\web\CController.php(1145): CFilter->filter(CFilterChain)
#22
+
C:\BitNami\wappstack-5.4.22-0\apache2\htdocs\yii\framework\web\filters\CInlineFilter.php(58): CController->filterAccessControl(CFilterChain)
#23
+
C:\BitNami\wappstack-5.4.22-0\apache2\htdocs\yii\framework\web\filters\CFilterChain.php(130): CInlineFilter->filter(CFilterChain)
#24
+
C:\BitNami\wappstack-5.4.22-0\apache2\htdocs\yii\framework\web\CController.php(291): CFilterChain->run()
#25
+
C:\BitNami\wappstack-5.4.22-0\apache2\htdocs\yii\framework\web\CController.php(265): CController->runActionWithFilters(CInlineAction, array("accessControl", "postOnly + delete"))
#26
+
C:\BitNami\wappstack-5.4.22-0\apache2\htdocs\yii\framework\web\CWebApplication.php(282): CController->run("senaraiPermohonan")
#27
+
C:\BitNami\wappstack-5.4.22-0\apache2\htdocs\yii\framework\web\CWebApplication.php(141): CWebApplication->runController("permohonan/senaraiPermohonan")
#28
+
C:\BitNami\wappstack-5.4.22-0\apache2\htdocs\yii\framework\base\CApplication.php(180): CWebApplication->processRequest()
#29
+
C:\BitNami\wappstack-5.4.22-0\apache2\htdocs\luar_negara\index.php(13): CApplication->run()

0

#6 User is offline   ahmad albab 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 39
  • Joined: 07-January 14

Posted 08 February 2014 - 11:20 PM

View Postahmad albab, on 08 February 2014 - 11:13 PM, said:

thank you oRey..:D
i attach pictures if you don't understand...


Attached File  error.png (88.9K)
Number of downloads: 34
Attached File  error1.png (202.03K)
Number of downloads: 31
Attached File  error2.png (203.91K)
Number of downloads: 15
Attached File  error3.png (234.65K)
Number of downloads: 12
0

#7 User is offline   ORey 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,701
  • Joined: 20-April 09
  • Location:Moscow, Russia

Posted 08 February 2014 - 11:25 PM

Seems like the problem is somewhere here
C:\BitNami\wappstack-5.4.22-0\apache2\htdocs\yii\framework\zii\widgets\grid\CDataColumn.php(137): CComponent->evaluateExpression("$data->neg->neg_lawat", array("data" => Permohonan, "row" => 4))


I guess that your 'neg' relation is null sometimes (left join), so calling $data->neg->neg_lawat will cause this error.

Also i think that Permohonan must be either quoted or dollar-signed ($Permohonan), so check your XController.
God is real unless declared as integer
0

#8 User is offline   ahmad albab 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 39
  • Joined: 07-January 14

Posted 08 February 2014 - 11:34 PM

View PostORey, on 08 February 2014 - 11:25 PM, said:

Seems like the problem is somewhere here
C:\BitNami\wappstack-5.4.22-0\apache2\htdocs\yii\framework\zii\widgets\grid\CDataColumn.php(137): CComponent->evaluateExpression("$data->neg->neg_lawat", array("data" => Permohonan, "row" => 4))


I guess that your 'neg' relation is null sometimes (left join), so calling $data->neg->neg_lawat will cause this error.

Also i think that Permohonan must be either quoted or dollar-signed ($Permohonan), so check your XController.


yes ! i got it !
i got to fix that error...
thank you so much, oRey...really appreciate it...:D

i hope you can help me next time...^^
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users