mysql - working with PHP notice Undefined variable -


i trying fix while can't. found several tutorials couldn't fix it.

my friend , working on same version, , works on pc without problem - me won't. using same files, copied mine him.

what matter here , why won't work on pc?

here index.php

<?php /* @var $this systemmanagementcontroller */ /* @var $dataprovider cactivedataprovider */ ?> <?php $this->breadcrumbs = array(     yii::t('mainmenu', 'system management'), );  $contenttabusers = $this->renderpartial('_tab_users', array(     'model'              => $usermodel,     'columns'            => $usercolumns,     ), $return               = true); $contenttabstates    = $this->renderpartial('_tab_states', array('model'                     => $statemodel), $return                    = true); $contenttabpriorities    = $this->renderpartial('_tab_priorities', null, $return                     = true); $contenttabproperties    = $this->renderpartial('_tab_properties', null, $return                     = true);  $upgradelog = 'tbd'; //new upgradelog();  $systeminfo = new systeminfo(); try {     $systeminfodata = array(         'system info'    => $systeminfo->getserverinfo(),         'apache'         => $systeminfo->getapacheinfo(),         'mysql info'     => $systeminfo->getmysqlinfo(),     ); } catch (exception $ex) {     yii::log('could not retrieve system info, exception thrown message: ' . $ex->getmessage(), clogger::level_error);     $systeminfodata = array(); } $contenttabsysinfo = $this->renderpartial('_tab_sysinfo', array( //  'model'                  => $upgradelog, //  'upgradelogdataprovider' => $this->getupgradelogdataprovider(), //  'upgradescripts'         => $this->getallinfoupgradescripts(),     'systeminfo' => $systeminfodata,     'phpinfo'    => $this->getbasicphpinfo(),     ), $return       = true );     // filter value show max lines $showmaxlines    = (int) $this->getapprequest()->getparam('log_show_max_lines', 50); $contenttablog   = $this->renderpartial('_tab_log', array(     'applicationlog' => $this->getlog($showmaxlines),     'showmaxlines'   => $showmaxlines,     // 'log_show_max_lines' placeholder js value in template     'filterurl'      => $this->getyiiapp()->createurl('systemmanagement/index', array('log_show_max_lines' => null)),     ), $return               = true ); yii::app()->user->setstate('activesystemmanagementtab', 'system_info');  $tabs = array(); if (yii::app()->user->checkaccess('systemmanagement.users')) {     $tabs[yii::t('systemmanagement', 'users')] = array('content'     => $contenttabusers, 'id'       => 'users'); } if (yii::app()->user->checkaccess('systemmanagement.states')) {     $tabs[yii::t('systemmanagement', 'states')] = array('content'    => $contenttabstates, 'id'      => 'states'); } if (yii::app()->user->checkaccess('systemmanagement.priorities')) {     $tabs[yii::t('systemmanagement', 'priorities')] = array('content'    => $contenttabpriorities, 'id'      => 'priorities'); } if (yii::app()->user->checkaccess('systemmanagement.properties')) {     $tabs[yii::t('systemmanagement', 'properties')] = array('content'    => $contenttabproperties, 'id'      => 'properties'); } if (yii::app()->user->checkaccess('systemmanagement.sysinfo')) {     $tabs[yii::t('systemmanagement', 'system info')] = array('content'   => $contenttabsysinfo, 'id'         => 'system_info'); } if (yii::app()->user->checkaccess('systemmanagement.log')) {     $tabs[yii::t('systemmanagement', 'log')] = array('content'   => $contenttablog, 'id'         => 'log'); }  $this->widget('zii.widgets.jui.cjuitabs', array(     'tabs'       => $tabs,     // additional javascript options tabs plugin     'options'    => array(         'collapsible'    => true,         'hide'           => 'fade',         'activetab'      => yii::app()->user->getstate('activesystemmanagementtab'), //      'show'           => 'highlight',         //todo @see http://www.bsourcecode.com/2012/11/how-to-handle-cjuitabs-in-yii/         'selected'       => isset(yii::app()->session['tabid']) ? yii::app()->session['tabid'] : 0,         'select'         => 'js:function(event, ui) {             var index=ui.index;             $.ajax({                 "url":"' . yii::app()->createurl('site/tabidsession') . '",                 "data":"tab="+index,             });     }',     )     ) ); ?> <script type="text/javascript">     function changeisactive(id)     {         $.ajax({             type: 'post',             url: "<?php echo yii::app()->createurl('usp/ajaxsetusponoff') ?>",             datatype: 'json',             data: "meid=" + id,             success: function (data) {                 // if page access denied show error msg                 var haserror = $("<div></div>").append(data).find("#content div.error").length > 0;                 if (haserror)                 {                     $("#flashmsg").show().addclass('flash-error').html('<?php echo yii::t('systemwide', 'you not authorized turn on/off element'); ?>').animate({opacity: 0.9}, 3500).fadeout("slow");                     return false;                 } else {                     if (data != 'error')                     {                         if (data)                         {                             $('#onoff_' + id).addclass(data);                         }                         else {                             $('#onoff_' + id).removeclass('checked');                         }                     }                     else                     {                         $("#flashmsg").show().addclass('flash-error').html('<?php echo yii::t('systemwide', 'you not authorized turn on/off element'); ?>').animate({opacity: 0.9}, 3500).fadeout("slow");                     }                     return false;                 }             },             error: function (jqxhr, exception) {                 $("#flashmsg").show().addclass('flash-error').html('<?php echo yii::t('systemwide', 'you not authorized turn on/off element'); ?>').animate({opacity: 0.9}, 3500).fadeout("slow");             }         });     } </script> 

when go server error:

php notice undefined variable: tabs /var/www/private/protected/views/systemmanagement/index.php(84)

and referring :

'tabs'       => $tabs, 

in order fix added, following on top of file:

$tabs = array(); 

now when this, works , doesn't give error, goes page , doesn't show content. please spending time on this.

if put in code:

print_r($systeminfodata);

i get:

array ( [system info] => array ( [os] => linux #36-ubuntu smp tue apr 10 20:39:51 utc 2012 [machine type] => x86_64 [server name] => 192.168.33.10 [server ip address] => 192.168.33.10 ) [apache] => array ( [version] => apache/2.4.12 (ubuntu) [loaded modules] => core, mod_so, mod_watchdog, http_core, mod_log_config, mod_logio, mod_version, mod_unixd, mod_access_compat, mod_alias, mod_auth_basic, mod_authn_core, mod_authn_file, mod_authz_core, mod_authz_groupfile, mod_authz_host, mod_authz_user, mod_autoindex, mod_cgi, mod_deflate, mod_dir, mod_env, mod_expires, mod_filter, mod_headers, mod_include, mod_mime, prefork, mod_negotiation, mod_php5, mod_reqtimeout, mod_rewrite, mod_setenvif, mod_status ) [mysql info] => array ( [server version] => 5.5.43-0ubuntu0.12.04.1 [meta information] => uptime: 11334 threads: 1 questions: 11476 slow queries: 0 opens: 76 flush tables: 1 open tables: 54 queries per second avg: 1.012 ) ) 

the problem caused variable $tabs not being defined.

you have 2 options, rightly mentioned other contributos:

i. (preferable)

define variable before using it.

ii. (not recommended)

the error not shown on friend's pc because of error_reporting level set in his/her environment. edit error_reporting level defined in php.ini.

in order hide php notices add or edit following line in php.ini

error_reporting = e_all & ~e_notice; 

alternatively can set error reporting level directly script follows:

// report errors except e_notice error_reporting(e_all & ~e_notice); 

read more error reporting in php here: http://php.net/manual/en/function.error-reporting.php


Comments

Popular posts from this blog

android - Pass an Serializable object in AIDL -

How to provide Authorization & Authentication using Asp.net, C#? -

How to use Authorization & Authentication in Asp.net, C#? -